FIX: wallets from keychain were not being loaded

This commit is contained in:
Marcos Rodriguez Vélez 2021-09-22 21:53:22 -04:00 committed by Overtorment
parent b2d9f8db0f
commit 2d332f8745

View File

@ -25,6 +25,11 @@ class WatchDataSource: NSObject, WCSessionDelegate {
override init() {
super.init()
if let existingData = keychain.getData(Wallet.identifier), let walletData = ((try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(existingData) as? [Wallet]) as [Wallet]??) {
guard let walletData = walletData, walletData != self.wallets else { return }
wallets = walletData
WatchDataSource.postDataUpdatedNotification()
}
if WCSession.isSupported() {
print("Activating watch session")
WCSession.default.delegate = self
@ -123,11 +128,6 @@ class WatchDataSource: NSObject, WCSessionDelegate {
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
if activationState == .activated {
if let existingData = keychain.getData(Wallet.identifier), let walletData = ((try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(existingData) as? [Wallet]) as [Wallet]??) {
guard let walletData = walletData, walletData != self.wallets else { return }
wallets = walletData
WatchDataSource.postDataUpdatedNotification()
}
WCSession.default.sendMessage(["message" : "sendApplicationContext"], replyHandler: { (replyData) in
}) { (error) in
print(error)