Skip to content

Commit

Permalink
Onboarding: keycard pin-related delays parametrized
Browse files Browse the repository at this point in the history
Closes: #17031
  • Loading branch information
micieslak committed Jan 9, 2025
1 parent 4ba5aa6 commit 015bf15
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 17 deletions.
7 changes: 5 additions & 2 deletions storybook/qmlTests/tests/tst_OnboardingLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ Item {

OnboardingLayout {
anchors.fill: parent

networkChecksEnabled: false
biometricsAvailable: mockDriver.biometricsAvailable
keycardPinInfoPageDelay: 0

onboardingStore: OnboardingStore {
readonly property int keycardState: mockDriver.keycardState // enum Onboarding.KeycardState
property int keycardRemainingPinAttempts: 5
Expand Down Expand Up @@ -70,6 +74,7 @@ Item {
}
function inputConnectionStringForBootstrapping(connectionString: string) {}
}

metricsStore: SharedStores.MetricsStore {
readonly property var d: QtObject {
id: d
Expand All @@ -85,8 +90,6 @@ Item {
readonly property bool isCentralizedMetricsEnabled : d.isCentralizedMetricsEnabled
}

biometricsAvailable: mockDriver.biometricsAvailable

QtObject {
id: localAppSettings
property bool metricsPopupSeen
Expand Down
13 changes: 9 additions & 4 deletions ui/app/AppLayouts/Onboarding2/KeycardCreateProfileFlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ import QtQuick 2.15
import QtQuick.Controls 2.15

import StatusQ.Core.Utils 0.1 as SQUtils
import StatusQ.Core.Backpressure 0.1

import AppLayouts.Onboarding2.pages 1.0
import AppLayouts.Onboarding.enums 1.0



SQUtils.QObject {
id: root

required property StackView stackView

required property int keycardState
required property int addKeyPairState
required property int keycardPinInfoPageDelay

required property var seedWords
required property var isSeedPhraseValid
Expand Down Expand Up @@ -166,10 +169,12 @@ SQUtils.QObject {
id: keycardCreatePinPage

KeycardCreatePinPage {
onKeycardPinCreated: {
root.keycardPinCreated(pin)
root.keyPairTransferRequested()
root.stackView.push(addKeypairPage)
onKeycardPinCreated: (pin) => {
Backpressure.debounce(root, root.keycardPinInfoPageDelay, () => {
root.keycardPinCreated(pin)
root.keyPairTransferRequested()
root.stackView.push(addKeypairPage)
})()
}
}
}
Expand Down
19 changes: 13 additions & 6 deletions ui/app/AppLayouts/Onboarding2/LoginWithKeycardFlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15

import StatusQ.Core.Utils 0.1 as SQUtils
import StatusQ.Core.Backpressure 0.1

import AppLayouts.Onboarding2.pages 1.0
import AppLayouts.Onboarding.enums 1.0
Expand All @@ -16,6 +17,8 @@ SQUtils.QObject {
required property int remainingAttempts
required property var isSeedPhraseValid

required property int keycardPinInfoPageDelay

property bool displayKeycardPromoBanner

signal keycardPinEntered(string pin)
Expand Down Expand Up @@ -85,9 +88,11 @@ SQUtils.QObject {
remainingAttempts: root.remainingAttempts
unlockUsingSeedphrase: true

onKeycardPinEntered: {
root.keycardPinEntered(pin)
root.finished()
onKeycardPinEntered: (pin) => {
Backpressure.debounce(root, root.keycardPinInfoPageDelay, () => {
root.keycardPinEntered(pin)
root.finished()
})()
}

onReloadKeycardRequested: d.reload()
Expand All @@ -114,9 +119,11 @@ SQUtils.QObject {
id: keycardCreatePinPage

KeycardCreatePinPage {
onKeycardPinCreated: {
root.keycardPinCreated(pin)
root.finished()
onKeycardPinCreated: (pin) => {
Backpressure.debounce(root, root.keycardPinInfoPageDelay, () => {
root.keycardPinCreated(pin)
root.finished()
})()
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions ui/app/AppLayouts/Onboarding2/OnboardingFlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ SQUtils.QObject {
required property bool displayKeycardPromoBanner
required property bool networkChecksEnabled

property int keycardPinInfoPageDelay: 2000

// functions
required property var passwordStrengthScoreFunction
required property var isSeedPhraseValid
Expand Down Expand Up @@ -161,6 +163,8 @@ SQUtils.QObject {
displayKeycardPromoBanner: root.displayKeycardPromoBanner
isSeedPhraseValid: root.isSeedPhraseValid

keycardPinInfoPageDelay: root.keycardPinInfoPageDelay

onReloadKeycardRequested: root.reloadKeycardRequested()
onKeycardFactoryResetRequested: root.keycardFactoryResetRequested()
onKeyPairTransferRequested: root.keyPairTransferRequested()
Expand Down Expand Up @@ -216,6 +220,8 @@ SQUtils.QObject {
tryToSetPinFunction: root.tryToSetPinFunction
isSeedPhraseValid: root.isSeedPhraseValid

keycardPinInfoPageDelay: root.keycardPinInfoPageDelay

onKeycardPinEntered: (pin) => root.keycardPinEntered(pin)
onKeycardPinCreated: (pin) => root.keycardPinCreated(pin)
onSeedphraseSubmitted: (seedphrase) => root.seedphraseSubmitted(seedphrase)
Expand Down
1 change: 1 addition & 0 deletions ui/app/AppLayouts/Onboarding2/OnboardingLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Page {

property bool biometricsAvailable: Qt.platform.os === Constants.mac
property bool networkChecksEnabled: true
property alias keycardPinInfoPageDelay: onboardingFlow.keycardPinInfoPageDelay

readonly property alias stack: stack

Expand Down
3 changes: 1 addition & 2 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardCreatePinPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Controls.Validators 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Backpressure 0.1

import AppLayouts.Onboarding2.controls 1.0

Expand Down Expand Up @@ -103,7 +102,7 @@ KeycardBasePage {
StateChangeScript {
script: {
pinInput.setPin(d.pin)
Backpressure.debounce(root, 2000, () => root.keycardPinCreated(d.pin))()
root.keycardPinCreated(d.pin)
}
}
},
Expand Down
4 changes: 1 addition & 3 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardEnterPinPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ KeycardBasePage {
enabled: false
}
StateChangeScript {
script: {
Backpressure.debounce(root, 2000, () => root.keycardPinEntered(pinInput.pinInput))()
}
script: root.keycardPinEntered(pinInput.pinInput)
}
},
State {
Expand Down

0 comments on commit 015bf15

Please sign in to comment.