Skip to content

Commit

Permalink
Merge pull request #1111 from radixdlt/bugfix/incompatible-wallet-on-…
Browse files Browse the repository at this point in the history
…restore

Catch errors when saving cloud profile snapshot locally
  • Loading branch information
micbakos-rdx authored Jul 31, 2024
2 parents 01c9131 + c592d8c commit e0cf303
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import rdx.works.core.sargon.isCompatible
import rdx.works.core.then
import rdx.works.profile.cloudbackup.data.GoogleSignInManager
import rdx.works.profile.cloudbackup.model.GoogleAccount
import rdx.works.profile.data.repository.HostInfoRepository
Expand Down Expand Up @@ -185,22 +186,22 @@ class RestoreFromBackupViewModel @Inject constructor(

downloadBackedUpProfileFromCloud(
entity = restoringProfile.entity
).fold(
onSuccess = { cloudBackupFile ->
val backupType = BackupType.Cloud(restoringProfile.entity)
saveTemporaryRestoringSnapshotUseCase.forCloud(cloudBackupFile.serializedProfile, backupType)
_state.update { it.copy(isDownloadingSelectedCloudBackup = false) }
sendEvent(Event.OnRestoreConfirmed(backupType))
},
onFailure = { exception ->
_state.update {
it.copy(
uiMessage = UiMessage.ErrorMessage(exception),
isDownloadingSelectedCloudBackup = false
)
}
).then { cloudBackupFile ->
val backupType = BackupType.Cloud(restoringProfile.entity)
saveTemporaryRestoringSnapshotUseCase.forCloud(cloudBackupFile.serializedProfile, backupType).map {
backupType
}
)
}.onSuccess { backupType ->
_state.update { it.copy(isDownloadingSelectedCloudBackup = false) }
sendEvent(Event.OnRestoreConfirmed(backupType))
}.onFailure { exception ->
_state.update {
it.copy(
uiMessage = UiMessage.ErrorMessage(exception),
isDownloadingSelectedCloudBackup = false
)
}
}
}

is State.RestoringProfile.DeprecatedCloudBackup -> sendEvent(Event.OnRestoreConfirmed(BackupType.DeprecatedCloud))
Expand Down

0 comments on commit e0cf303

Please sign in to comment.