Skip to content

Commit b9d59e9

Browse files
committed
fix: kyoto could get into .notStarted state
1 parent c15e6e6 commit b9d59e9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

BDKSwiftExampleWallet/View Model/WalletViewModel.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ class WalletViewModel {
9797
) { [weak self] notification in
9898
if let progress = notification.userInfo?["progress"] as? Float {
9999
self?.updateKyotoProgress(progress)
100+
101+
// Update sync state based on Kyoto progress
102+
if progress >= 100 {
103+
self?.walletSyncState = .synced
104+
} else if progress > 0 {
105+
self?.walletSyncState = .syncing
106+
}
100107
}
101108
}
102109

@@ -107,6 +114,16 @@ class WalletViewModel {
107114
) { [weak self] notification in
108115
if let connected = notification.userInfo?["connected"] as? Bool {
109116
self?.isKyotoConnected = connected
117+
118+
// When Kyoto connects, update sync state if needed
119+
if connected && self?.walletSyncState == .notStarted {
120+
// Check current progress to determine state
121+
if let progress = self?.progress, progress >= 100 {
122+
self?.walletSyncState = .synced
123+
} else {
124+
self?.walletSyncState = .syncing
125+
}
126+
}
110127
}
111128
}
112129

0 commit comments

Comments
 (0)