From e29e93e97d35d21dc095688a40f074572488486a Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 19 Jan 2024 11:53:28 +0700 Subject: [PATCH] TF-2464 Save keychain as data Signed-off-by: dab246 --- ios/TwakeMailNSE/Keychain/KeychainController.swift | 12 ++++++------ ios/TwakeMailNSE/Model/KeychainSharingSession.swift | 7 ------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/ios/TwakeMailNSE/Keychain/KeychainController.swift b/ios/TwakeMailNSE/Keychain/KeychainController.swift index a2bacbf4bd..b54321c0b1 100644 --- a/ios/TwakeMailNSE/Keychain/KeychainController.swift +++ b/ios/TwakeMailNSE/Keychain/KeychainController.swift @@ -42,18 +42,18 @@ class KeychainController: KeychainControllerDelegate { func updateEmailDeliveryStateToKeychain(accountId: String, newEmailDeliveryState: String) { do { - if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId) { - let newSharingSession = sharingSession.updateEmailDeliveryState(newEmailDeliveryState: newEmailDeliveryState) - try keychain.set(newSharingSession.toJson() ?? "", key: accountId) + if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId), + let newSharingSessionData = sharingSession.updateEmailDeliveryState(newEmailDeliveryState: newEmailDeliveryState).toData() { + try keychain.set(newSharingSessionData, key: accountId) } } catch {} } func updateTokenOidc(accountId: String, newTokenOidc: TokenOidc) { do { - if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId) { - let newSharingSession = sharingSession.updateTokenOidc(newTokenOidc: newTokenOidc) - try keychain.set(newSharingSession.toJson() ?? "", key: accountId) + if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId), + let newSharingSessionData = sharingSession.updateTokenOidc(newTokenOidc: newTokenOidc).toData() { + try keychain.set(newSharingSessionData, key: accountId) } } catch {} } diff --git a/ios/TwakeMailNSE/Model/KeychainSharingSession.swift b/ios/TwakeMailNSE/Model/KeychainSharingSession.swift index 47bd690b43..4567d9cc5d 100644 --- a/ios/TwakeMailNSE/Model/KeychainSharingSession.swift +++ b/ios/TwakeMailNSE/Model/KeychainSharingSession.swift @@ -55,11 +55,4 @@ extension KeychainSharingSession { } return nil } - - func toJson() -> String? { - if let data = toData(), let jsonString = String(data: data, encoding: .utf8) { - return jsonString - } - return nil - } }