fix(@desktop/onboarding): back button actions fixed part 1/2
This commit is contained in:
parent
3ca03bdd49
commit
2146843e93
|
@ -178,6 +178,9 @@ proc getImportedAccount*(self: Controller): GeneratedAccountDto =
|
|||
proc getPasswordStrengthScore*(self: Controller, password, userName: string): int =
|
||||
return self.generalService.getPasswordStrengthScore(password, userName)
|
||||
|
||||
proc clearImage*(self: Controller) =
|
||||
self.tmpProfileImageDetails = ProfileImageDetails()
|
||||
|
||||
proc generateImage*(self: Controller, imageUrl: string, aX: int, aY: int, bX: int, bY: int): string =
|
||||
let formatedImg = singletonInstance.utils.formatImagePath(imageUrl)
|
||||
let images = self.generalService.generateImages(formatedImg, aX, aY, bX, bY)
|
||||
|
|
|
@ -13,10 +13,6 @@ proc delete*(self: KeycardCreatePinState) =
|
|||
method executeBackCommand*(self: KeycardCreatePinState, controller: Controller) =
|
||||
controller.setPin("")
|
||||
controller.setPinMatch(false)
|
||||
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys or
|
||||
self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard or
|
||||
self.flowType == FlowType.FirstRunOldUserKeycardImport:
|
||||
controller.cancelCurrentFlow()
|
||||
|
||||
method getNextPrimaryState*(self: KeycardCreatePinState, controller: Controller): State =
|
||||
if not self.pinValid:
|
||||
|
|
|
@ -40,6 +40,19 @@ method resolveKeycardNextState*(self: KeycardEnterPinState, keycardFlowType: str
|
|||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.KeycardWrongPin, self.flowType, self.getBackState)
|
||||
return createState(StateType.KeycardMaxPinRetriesReached, self.flowType, self.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len == 0:
|
||||
if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardMaxPinRetriesReached, self.flowType, self.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUKRetries:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.MaxPUKReached, add = true))
|
||||
return createState(StateType.KeycardMaxPukRetriesReached, self.flowType, self.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamFreeSlots:
|
||||
return createState(StateType.KeycardMaxPairingSlotsReached, self.flowType, self.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult:
|
||||
controller.setKeycardEvent(keycardEvent)
|
||||
if not defined(macosx):
|
||||
|
|
|
@ -24,4 +24,5 @@ method resolveKeycardNextState*(self: KeycardEnterSeedPhraseWordsState, keycardF
|
|||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
keycardEvent.keyUid.len > 0:
|
||||
controller.setKeyUid(keycardEvent.keyUid)
|
||||
return createState(StateType.UserProfileCreate, self.flowType, self)
|
||||
let backState = findBackStateWithTargetedStateType(self, StateType.WelcomeNewStatusUser)
|
||||
return createState(StateType.UserProfileCreate, self.flowType, backState)
|
|
@ -40,16 +40,17 @@ method resolveKeycardNextState*(self: KeycardRepeatPinState, keycardFlowType: st
|
|||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
keycardEvent.keyUid.len > 0:
|
||||
controller.setKeyUid(keycardEvent.keyUid)
|
||||
return createState(StateType.KeycardPinSet, self.flowType, self.getBackState)
|
||||
let backState = findBackStateWithTargetedStateType(self, StateType.UserProfileImportSeedPhrase)
|
||||
return createState(StateType.KeycardPinSet, self.flowType, backState)
|
||||
if self.flowType == FlowType.FirstRunOldUserKeycardImport:
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
controller.setPukValid(false)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardPinSet, self.flowType, self.getBackState)
|
||||
return createState(StateType.KeycardMaxPukRetriesReached, self.flowType, self.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK:
|
||||
if keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
controller.setPukValid(false)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardPinSet, self.flowType, self.getBackState)
|
||||
return createState(StateType.KeycardMaxPukRetriesReached, self.flowType, self.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult:
|
||||
controller.setKeycardEvent(keycardEvent)
|
||||
controller.setPukValid(true)
|
||||
|
|
|
@ -36,6 +36,15 @@ method resolveKeycardNextState*(self: KeycardWrongPinState, keycardFlowType: str
|
|||
if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardMaxPinRetriesReached, self.flowType, self.getBackState)
|
||||
return nil
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUKRetries:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.MaxPUKReached, add = true))
|
||||
return createState(StateType.KeycardMaxPukRetriesReached, self.flowType, self.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamFreeSlots:
|
||||
return createState(StateType.KeycardMaxPairingSlotsReached, self.flowType, self.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult:
|
||||
controller.setKeycardEvent(keycardEvent)
|
||||
if not defined(macosx):
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
proc ensureReaderAndCardPresenceOnboarding*(state: State, keycardFlowType: string, keycardEvent: KeycardEvent, controller: Controller): State =
|
||||
var defaultBackState = state
|
||||
if state.flowType == FlowType.FirstRunNewUserNewKeycardKeys and
|
||||
state.stateType == StateType.KeycardEmpty:
|
||||
## `KeycardEmpty` state is known in the context of `FirstRunNewUserNewKeycardKeys` only if we jump to it from
|
||||
## `FirstRunOldUserKeycardImport` flow, in that case we need to set back state appropriatelly respecting different flow.
|
||||
defaultBackState = state.getBackState
|
||||
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorConnection:
|
||||
controller.resumeCurrentFlowLater()
|
||||
if state.stateType == StateType.KeycardPluginReader:
|
||||
return nil
|
||||
return createState(StateType.KeycardPluginReader, state.flowType, state)
|
||||
return createState(StateType.KeycardPluginReader, state.flowType, defaultBackState)
|
||||
if keycardFlowType == ResponseTypeValueInsertCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorConnection:
|
||||
|
@ -13,12 +20,12 @@ proc ensureReaderAndCardPresenceOnboarding*(state: State, keycardFlowType: strin
|
|||
return nil
|
||||
if state.stateType == StateType.KeycardPluginReader:
|
||||
return createState(StateType.KeycardInsertKeycard, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardInsertKeycard, state.flowType, state)
|
||||
return createState(StateType.KeycardInsertKeycard, state.flowType, defaultBackState)
|
||||
if keycardFlowType == ResponseTypeValueCardInserted:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.WronglyInsertedCard, add = false))
|
||||
if state.stateType == StateType.KeycardInsertKeycard:
|
||||
return createState(StateType.KeycardInsertedKeycard, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardInsertedKeycard, state.flowType, state)
|
||||
return createState(StateType.KeycardInsertedKeycard, state.flowType, defaultBackState)
|
||||
|
||||
proc ensureReaderAndCardPresenceAndResolveNextOnboardingState*(state: State, keycardFlowType: string, keycardEvent: KeycardEvent, controller: Controller): State =
|
||||
let ensureState = ensureReaderAndCardPresenceOnboarding(state, keycardFlowType, keycardEvent, controller)
|
||||
|
@ -26,89 +33,98 @@ proc ensureReaderAndCardPresenceAndResolveNextOnboardingState*(state: State, key
|
|||
return ensureState
|
||||
|
||||
if state.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
|
||||
var backState = state.getBackState
|
||||
if state.stateType == StateType.WelcomeNewStatusUser:
|
||||
backState = state
|
||||
|
||||
if state.stateType == StateType.KeycardEmpty:
|
||||
## `KeycardEmpty` state is known in the context of `FirstRunNewUserNewKeycardKeys` only if we jump to it from
|
||||
## `FirstRunOldUserKeycardImport` flow, in that case we need to set back state appropriatelly respecting different flow.
|
||||
backState = state.getBackState
|
||||
|
||||
if keycardFlowType == ResponseTypeValueEnterNewPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorRequireInit:
|
||||
return createState(StateType.KeycardRecognizedKeycard, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardRecognizedKeycard, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len == 0:
|
||||
return createState(StateType.KeycardNotEmpty, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardNotEmpty, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len == 0:
|
||||
if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardLocked, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardLocked, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0:
|
||||
if keycardEvent.error == ErrorNotAKeycard:
|
||||
return createState(StateType.KeycardNotKeycard, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardNotKeycard, state.flowType, backState)
|
||||
if keycardEvent.error == RequestParamFreeSlots:
|
||||
return createState(StateType.KeycardLocked, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardLocked, state.flowType, backState)
|
||||
if keycardEvent.error == RequestParamPUKRetries:
|
||||
return createState(StateType.KeycardLocked, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardLocked, state.flowType, backState)
|
||||
if keycardEvent.error == ErrorHasKeys:
|
||||
return createState(StateType.KeycardNotEmpty, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardNotEmpty, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueEnterMnemonic and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorLoadingKeys:
|
||||
controller.buildSeedPhrasesFromIndexes(keycardEvent.seedPhraseIndexes)
|
||||
return createState(StateType.KeycardPinSet, state.flowType, state.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
keycardEvent.keyUid.len > 0:
|
||||
controller.setKeyUid(keycardEvent.keyUid)
|
||||
return createState(StateType.UserProfileCreate, state.flowType, state)
|
||||
return createState(StateType.KeycardPinSet, state.flowType, backState)
|
||||
|
||||
if state.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
|
||||
var backState = state.getBackState
|
||||
if state.stateType == StateType.UserProfileImportSeedPhrase:
|
||||
backState = state
|
||||
|
||||
if keycardFlowType == ResponseTypeValueEnterNewPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorRequireInit:
|
||||
if state.stateType == StateType.UserProfileEnterSeedPhrase:
|
||||
return createState(StateType.KeycardCreatePin, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardRecognizedKeycard, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardCreatePin, state.flowType, backState)
|
||||
return createState(StateType.KeycardRecognizedKeycard, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len == 0:
|
||||
return createState(StateType.KeycardNotEmpty, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardNotEmpty, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0:
|
||||
if keycardEvent.error == ErrorNotAKeycard:
|
||||
return createState(StateType.KeycardNotKeycard, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardNotKeycard, state.flowType, backState)
|
||||
if keycardEvent.error == RequestParamFreeSlots:
|
||||
return createState(StateType.KeycardLocked, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardLocked, state.flowType, backState)
|
||||
if keycardEvent.error == RequestParamPUKRetries:
|
||||
return createState(StateType.KeycardLocked, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardLocked, state.flowType, backState)
|
||||
if keycardEvent.error == ErrorHasKeys:
|
||||
return createState(StateType.KeycardNotEmpty, state.flowType, state.getBackState)
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
keycardEvent.keyUid.len > 0:
|
||||
controller.setKeyUid(keycardEvent.keyUid)
|
||||
return createState(StateType.KeycardPinSet, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardNotEmpty, state.flowType, backState)
|
||||
|
||||
if state.flowType == FlowType.FirstRunOldUserKeycardImport:
|
||||
var backState = state.getBackState
|
||||
if state.stateType == StateType.RecoverOldUser:
|
||||
backState = state
|
||||
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.MaxPUKReached, add = false))
|
||||
controller.setKeyUid(keycardEvent.keyUid)
|
||||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len == 0:
|
||||
return createState(StateType.KeycardRecognizedKeycard, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardRecognizedKeycard, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len == 0:
|
||||
if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardMaxPinRetriesReached, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardMaxPinRetriesReached, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorNoKeys:
|
||||
return createState(StateType.KeycardEmpty, state.flowType, nil)
|
||||
return createState(StateType.KeycardEmpty, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUKRetries:
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.MaxPUKReached, add = true))
|
||||
return createState(StateType.KeycardMaxPukRetriesReached, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardMaxPukRetriesReached, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamFreeSlots:
|
||||
return createState(StateType.KeycardMaxPairingSlotsReached, state.flowType, state.getBackState)
|
||||
return createState(StateType.KeycardMaxPairingSlotsReached, state.flowType, backState)
|
||||
if keycardFlowType == ResponseTypeValueEnterNewPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorRequireInit:
|
||||
return createState(StateType.KeycardCreatePin, state.flowType, nil)
|
||||
return createState(StateType.KeycardCreatePin, state.flowType, backState)
|
||||
|
||||
if state.flowType == FlowType.AppLogin:
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
|
|
|
@ -20,4 +20,5 @@ method getNextPrimaryState*(self: UserProfileCreateState, controller: Controller
|
|||
return createState(StateType.UserProfileChatKey, self.flowType, self)
|
||||
|
||||
method executeBackCommand*(self: UserProfileCreateState, controller: Controller) =
|
||||
controller.setDisplayName("")
|
||||
controller.setDisplayName("")
|
||||
controller.clearImage()
|
|
@ -23,7 +23,7 @@ method getNextPrimaryState*(self: UserProfileEnterSeedPhraseState, controller: C
|
|||
return createState(StateType.UserProfileCreate, self.flowType, self)
|
||||
if self.flowType == FlowType.FirstRunOldUserKeycardImport:
|
||||
if not self.enteredMnemonicMatchTargetedKeyUid:
|
||||
return createState(StateType.KeycardWrongKeycard, self.flowType, nil)
|
||||
return createState(StateType.KeycardWrongKeycard, self.flowType, self)
|
||||
if self.flowType == FlowType.FirstRunOldUserImportSeedPhrase:
|
||||
return createState(StateType.UserProfileCreatePassword, self.flowType, self)
|
||||
|
||||
|
|
|
@ -458,13 +458,15 @@ method onSharedKeycarModuleFlowTerminated*[T](self: Module[T], lastStepInTheCurr
|
|||
if currStateObj.isNil:
|
||||
error "cannot resolve current state for onboarding/login flow continuation"
|
||||
return
|
||||
if currStateObj.flowType() == FlowType.LostKeycardReplacement:
|
||||
let newState = currStateObj.getBackState()
|
||||
if newState.isNil:
|
||||
error "cannot resolve new state for onboarding/login flow continuation after shared flow is terminated"
|
||||
return
|
||||
self.view.setCurrentStartupState(newState)
|
||||
debug "new state for onboarding/login flow continuation after shared flow is terminated", setCurrFlow=newState.flowType(), newCurrState=newState.stateType()
|
||||
if currStateObj.flowType() == FlowType.FirstRunNewUserNewKeycardKeys or
|
||||
currStateObj.flowType() == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard or
|
||||
currStateObj.flowType() == FlowType.LostKeycardReplacement:
|
||||
let newState = currStateObj.getBackState()
|
||||
if newState.isNil:
|
||||
error "cannot resolve new state for onboarding/login flow continuation after shared flow is terminated"
|
||||
return
|
||||
self.view.setCurrentStartupState(newState)
|
||||
debug "new state for onboarding/login flow continuation after shared flow is terminated", setCurrFlow=newState.flowType(), newCurrState=newState.stateType()
|
||||
|
||||
method storeKeyPairForNewKeycardUser*[T](self: Module[T]) =
|
||||
self.delegate.storeKeyPairForNewKeycardUser()
|
||||
|
|
|
@ -403,7 +403,7 @@ Item {
|
|||
}
|
||||
PropertyChanges {
|
||||
target: txtDesc
|
||||
text: qsTr("Seed phrases are used to back up and restore your keys. Only use this option if you already have a seed phrase.")
|
||||
text: qsTr("Seed phrases are used to back up and restore your keys.\nOnly use this option if you already have a seed phrase.")
|
||||
height: Constants.onboarding.loginInfoHeight2
|
||||
}
|
||||
PropertyChanges {
|
||||
|
|
Loading…
Reference in New Issue