[#1173] Persist info about restore until it is done

- The restoration of the wallet is persisted until it's done (up-to date/synced) at some point in the future
This commit is contained in:
Lukas Korba 2024-04-04 11:31:02 +02:00
parent ff5b6ce0ef
commit 52a2f6b0a9
4 changed files with 34 additions and 12 deletions

View File

@ -8,15 +8,17 @@ directly impact users rather than highlighting other crucial architectural updat
### Added
- Open settings button added to the scan screen for a case when the camera is disabled.
- Content of Zashi is hidden in system's app switcher.
- Birthday field is auto-focused in the restore flow.
- Information about restore is persisted until fully synced wallet.
### Changed
- Zashi requires 1 GB of free space to operate. We have updated the user experience to display a message when this requirement is not met, indicating the actual amount of free space available. From this screen, you can access the settings to obtain the recovery phrase if needed.
## 1.0.4 build 2 (2024-03-29)
### Added
- Tap to Copy memo.
- Content of Zashi is hidden in system's app switcher.
### Changed
- Zashi requires 1 GB of free space to operate. We have updated the user experience to display a message when this requirement is not met, indicating the actual amount of free space available. From this screen, you can access the settings to obtain the recovery phrase if needed.
### Fixed
- Tap to Copy transaction ID button animation.

View File

@ -422,6 +422,7 @@ let package = Package(
"SDKSynchronizer",
"Tabs",
"UIComponents",
"UserDefaults",
"UserPreferencesStorage",
"Utils",
"WalletConfigProvider",

View File

@ -15,6 +15,10 @@ import Utils
/// In this file is a collection of helpers that control all state and action related operations
/// for the `RootReducer` with a connection to the app/wallet initialization and erasure of the wallet.
extension RootReducer {
public enum Constants {
static let udIsRestoringWallet = "udIsRestoringWallet"
}
public enum InitializationAction: Equatable {
case appDelegate(AppDelegateAction)
case checkBackupPhraseValidation
@ -122,6 +126,7 @@ extension RootReducer {
case .initialization(.checkRestoreWalletFlag(let syncStatus)):
if state.isRestoringWallet && syncStatus == .upToDate {
state.isRestoringWallet = false
userDefaults.remove(Constants.udIsRestoringWallet)
return .run { _ in
await restoreWalletStorage.updateValue(false)
}
@ -221,9 +226,21 @@ extension RootReducer {
case .keysMissing:
state.appInitializationState = .keysMissing
return .send(.destination(.updateDestination(.onboarding)))
case .initialized, .filesMissing:
if walletState == .filesMissing {
state.appInitializationState = .filesMissing
case .filesMissing:
state.appInitializationState = .filesMissing
state.isRestoringWallet = true
userDefaults.setValue(true, Constants.udIsRestoringWallet)
return .concatenate(
.merge(
Effect.send(.initialization(.initializeSDK(.restoreWallet))),
.run { _ in
await restoreWalletStorage.updateValue(true)
}
),
Effect.send(.initialization(.checkBackupPhraseValidation))
)
case .initialized:
if let isRestoringWallet = userDefaults.objectForKey(Constants.udIsRestoringWallet) as? Bool, isRestoringWallet {
state.isRestoringWallet = true
return .concatenate(
.merge(
@ -234,12 +251,11 @@ extension RootReducer {
),
Effect.send(.initialization(.checkBackupPhraseValidation))
)
} else {
return .concatenate(
Effect.send(.initialization(.initializeSDK(.existingWallet))),
Effect.send(.initialization(.checkBackupPhraseValidation))
)
}
return .concatenate(
Effect.send(.initialization(.initializeSDK(.existingWallet))),
Effect.send(.initialization(.checkBackupPhraseValidation))
)
case .uninitialized:
state.appInitializationState = .uninitialized
return .run { send in
@ -430,6 +446,7 @@ extension RootReducer {
case .onboarding(.importWallet(.initializeSDK)):
state.isRestoringWallet = true
userDefaults.setValue(true, Constants.udIsRestoringWallet)
return .merge(
Effect.send(.initialization(.initializeSDK(.restoreWallet))),
.run { _ in

View File

@ -22,6 +22,7 @@ import RecoveryPhraseDisplay
import BackgroundTasks
import RestoreWalletStorage
import Utils
import UserDefaults
public typealias RootStore = Store<RootReducer.State, RootReducer.Action>
public typealias RootViewStore = ViewStore<RootReducer.State, RootReducer.Action>
@ -124,6 +125,7 @@ public struct RootReducer: Reducer {
@Dependency(\.numberFormatter) var numberFormatter
@Dependency(\.pasteboard) var pasteboard
@Dependency(\.sdkSynchronizer) var sdkSynchronizer
@Dependency(\.userDefaults) var userDefaults
@Dependency(\.userStoredPreferences) var userStoredPreferences
@Dependency(\.walletConfigProvider) var walletConfigProvider
@Dependency(\.walletStorage) var walletStorage