Skip to content

Commit d281472

Browse files
committed
fix(onboarding): Delay the keycard detection for when keycard is needed
This is a fix for the mobile platforms that will show a drawer when the keycard is needed. We'll need to avoid showing the drawer every time at app start.
1 parent 1bb9a1e commit d281472

File tree

9 files changed

+37
-3
lines changed

9 files changed

+37
-3
lines changed

src/app/modules/onboarding/controller.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,6 @@ proc storeMetadataAsync*(self: Controller, name: string, paths: seq[string]) =
272272

273273
proc asyncImportLocalBackupFile*(self: Controller, filePath: string) =
274274
self.generalService.asyncImportLocalBackupFile(filePath)
275+
276+
proc startKeycardDetection*(self: Controller) =
277+
self.keycardServiceV2.startDetection()

src/app/modules/onboarding/io_interface.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ method requestDeleteBiometrics*(self: AccessInterface, account: string) {.base.}
109109
method requestLocalBackup*(self: AccessInterface, backupImportFileUrl: string) {.base.} =
110110
raise newException(ValueError, "No implementation available")
111111

112+
method startKeycardDetection*(self: AccessInterface) {.base.} =
113+
raise newException(ValueError, "No implementation available")
114+
112115
# This way (using concepts) is used only for the modules managed by AppController
113116
type
114117
DelegateInterface* = concept c

src/app/modules/onboarding/module.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ method requestLocalBackup*[T](self: Module[T], backupImportFileUrl: string) =
446446
method requestDeleteBiometrics*[T](self: Module[T], account: string) =
447447
self.view.deleteBiometricsRequested(account)
448448

449+
method startKeycardDetection*[T](self: Module[T]) =
450+
self.controller.startKeycardDetection()
451+
449452
proc runPostLoginTasks*[T](self: Module[T]) =
450453
let tasks = self.postLoginTasks
451454
for task in tasks:

src/app/modules/onboarding/view.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ QtObject:
195195
proc startKeycardFactoryReset(self: View) {.slot.} =
196196
self.delegate.startKeycardFactoryReset()
197197

198+
proc startKeycardDetection(self: View) {.slot.} =
199+
self.delegate.startKeycardDetection()
200+
198201
proc delete*(self: View) =
199202
self.QObject.delete
200203

src/app_service/service/keycardV2/service.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ QtObject:
262262
except Exception as e:
263263
error "error storing metadata", err=e.msg
264264

265+
proc startDetection*(self: Service) {.featureGuard(KEYCARD_ENABLED).} =
266+
self.asyncStart(status_const.KEYCARDPAIRINGDATAFILE)
267+
265268
proc delete*(self: Service) =
266269
self.QObject.delete
267270

ui/app/AppLayouts/Onboarding/OnboardingFlow.qml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ OnboardingStackView {
7272
signal linkActivated(string link)
7373

7474
signal finished(int flow)
75+
signal keycardRequested()
7576

7677
// Thirdparty services
7778
required property bool privacyModeFeatureEnabled
@@ -239,7 +240,7 @@ OnboardingStackView {
239240

240241
onUnblockWithSeedphraseRequested: root.push(unblockWithSeedphraseFlow)
241242
onUnblockWithPukRequested: root.push(unblockWithPukFlow)
242-
243+
onKeycardRequested: root.keycardRequested()
243244
onVisibleChanged: {
244245
if (!visible)
245246
root.dismissBiometricsRequested()
@@ -277,7 +278,10 @@ OnboardingStackView {
277278
root.push(useRecoveryPhraseFlow,
278279
{ type: UseRecoveryPhraseFlow.Type.NewProfile })
279280
}
280-
onCreateProfileWithEmptyKeycardRequested: root.push(keycardCreateProfileFlow)
281+
onCreateProfileWithEmptyKeycardRequested: {
282+
root.keycardRequested()
283+
root.push(keycardCreateProfileFlow)
284+
}
281285
}
282286
}
283287

@@ -290,7 +294,10 @@ OnboardingStackView {
290294
thirdpartyServicesEnabled: root.thirdpartyServicesEnabled
291295

292296
onLoginWithSyncingRequested: root.push(logInBySyncingFlow)
293-
onLoginWithKeycardRequested: root.push(loginWithKeycardFlow)
297+
onLoginWithKeycardRequested: {
298+
root.keycardRequested()
299+
root.push(loginWithKeycardFlow)
300+
}
294301

295302
onLoginWithSeedphraseRequested: {
296303
d.flow = Onboarding.OnboardingFlow.LoginWithSeedphrase

ui/app/AppLayouts/Onboarding/OnboardingLayout.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Page {
200200
onExportKeysRequested: root.onboardingStore.exportRecoverKeys()
201201
onImportLocalBackupRequested: (importFilePath) => d.backupImportFileUrl = importFilePath
202202
onFinished: (flow) => d.finishFlow(flow)
203+
onKeycardRequested: root.onboardingStore.startKeycardDetection()
203204

204205
onBiometricsRequested: (profileId) => {
205206
const isKeycardProfile = SQUtils.ModelUtils.getByKey(

ui/app/AppLayouts/Onboarding/pages/LoginScreen.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ OnboardingPage {
9191
signal unblockWithSeedphraseRequested()
9292
signal unblockWithPukRequested()
9393
signal lostKeycardFlowRequested()
94+
signal keycardRequested()
9495

9596
QtObject {
9697
id: d
@@ -104,6 +105,12 @@ OnboardingPage {
104105
readonly property int loginModelCount: root.loginAccountsModel.ModelCount.count
105106
onLoginModelCountChanged: setSelectedLoginUser()
106107

108+
onCurrentProfileIsKeycardChanged: {
109+
if (d.currentProfileIsKeycard) {
110+
root.keycardRequested()
111+
}
112+
}
113+
107114
function setSelectedLoginUser() {
108115
if (loginModelCount > 0) {
109116
loginUserSelector.setSelection(d.settings.lastKeyUid)

ui/app/AppLayouts/Onboarding/stores/OnboardingStore.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ QtObject {
3535
readonly property int keycardRemainingPinAttempts: d.onboardingModuleInst.keycardRemainingPinAttempts
3636
readonly property int keycardRemainingPukAttempts: d.onboardingModuleInst.keycardRemainingPukAttempts
3737

38+
function startKeycardDetection() {
39+
d.onboardingModuleInst.startKeycardDetection()
40+
}
41+
3842
function finishOnboardingFlow(flow: int, data: Object) { // -> string
3943
return d.onboardingModuleInst.finishOnboardingFlow(flow, JSON.stringify(data))
4044
}

0 commit comments

Comments
 (0)