fix(@desktop/onboarding): ignore applying fetched waku data if user didn’t follow recover account onboarding path

This commit is contained in:
Sale Djenic 2023-04-19 15:16:00 +02:00 committed by saledjenic
parent 87a4300e46
commit 61bd370b20
5 changed files with 21 additions and 7 deletions

View File

@ -112,7 +112,7 @@ proc tryKeycardSyncWithTheAppState(self: AppController)
# Startup Module Delegate Interface
proc startupDidLoad*(self: AppController)
proc userLoggedIn*(self: AppController): string
proc userLoggedIn*(self: AppController, recoverAccount: bool): string
proc logout*(self: AppController)
proc finishAppLoading*(self: AppController)
proc storeDefaultKeyPairForNewKeycardUser*(self: AppController)
@ -450,10 +450,10 @@ proc load(self: AppController) =
self.mailserversService,
)
proc userLoggedIn*(self: AppController): string =
proc userLoggedIn*(self: AppController, recoverAccount: bool): string =
try:
self.generalService.startMessenger()
self.statusFoundation.userLoggedIn()
self.statusFoundation.userLoggedIn(recoverAccount)
return ""
except Exception as e:
let errDescription = e.msg

View File

@ -34,5 +34,7 @@ proc initUrlSchemeManager*(self: StatusFoundation, urlSchemeEvent: StatusEvent,
self.urlsManager = newUrlsManager(self.events, urlSchemeEvent, singleInstance,
protocolUriOnStart)
proc userLoggedIn*(self: StatusFoundation) =
proc userLoggedIn*(self: StatusFoundation, recoverAccount: bool) =
self.urlsManager.userLoggedIn()
if recoverAccount:
self.signalsManager.doHandlingForDataComingFromWakuBackup()

View File

@ -9,6 +9,7 @@ logScope:
QtObject:
type SignalsManager* = ref object of QObject
events: EventEmitter
ignoreBackedUpData: bool
#################################################
# Forward declaration section
@ -25,6 +26,10 @@ QtObject:
new(result)
result.setup()
result.events = events
result.ignoreBackedUpData = true
proc doHandlingForDataComingFromWakuBackup*(self: SignalsManager) =
self.ignoreBackedUpData = false
proc processSignal(self: SignalsManager, statusSignal: string) =
var jsonSignal: JsonNode
@ -50,6 +55,13 @@ QtObject:
if(signal.signalType == SignalType.NodeCrashed):
error "node.crashed", error=statusSignal
if self.ignoreBackedUpData and
(signal.signalType == SignalType.WakuFetchingBackupProgress or
signal.signalType == SignalType.WakuBackedUpProfile or
signal.signalType == SignalType.WakuBackedUpSettings or
signal.signalType == SignalType.WakuBackedUpKeycards):
return
self.events.emit(signal.signalType.event, signal)
proc receiveSignal(self: SignalsManager, signal: string) {.slot.} =

View File

@ -188,7 +188,7 @@ method onReencryptionProcessStarted*(self: AccessInterface) {.base.} =
type
DelegateInterface* = concept c
c.startupDidLoad()
c.userLoggedIn()
c.userLoggedIn(bool)
c.finishAppLoading()
c.storeDefaultKeyPairForNewKeycardUser()
c.syncKeycardBasedOnAppWalletStateAfterLogin()

View File

@ -389,7 +389,7 @@ method onNodeLogin*[T](self: Module[T], error: string) =
self.prepareAndInitFetchingData()
self.controller.connectToFetchingFromWakuEvents()
self.delayStartingApp()
let err = self.delegate.userLoggedIn()
let err = self.delegate.userLoggedIn(recoverAccount = true)
if err.len > 0:
self.logoutAndDisplayError(err, StartupErrorType.UnknownType)
return
@ -402,7 +402,7 @@ method onNodeLogin*[T](self: Module[T], error: string) =
self.view.setCurrentStartupState(newLoginKeycardConvertedToRegularAccountState(currStateObj.flowType(), nil))
self.moveToStartupState()
else:
let err = self.delegate.userLoggedIn()
let err = self.delegate.userLoggedIn(recoverAccount = false)
if err.len > 0:
self.logoutAndDisplayError(err, StartupErrorType.UnknownType)
return