fix: double "login" event being emitted by login / onboarding
This commit is contained in:
parent
6874c7eb55
commit
6d6f67476b
|
@ -34,6 +34,7 @@ proc handleNodeStopped(self: LoginController, data: Signal) =
|
|||
self.view.onLoggedOut()
|
||||
|
||||
proc handleNodeLogin(self: LoginController, data: Signal) =
|
||||
if not self.view.isCurrentFlow: return
|
||||
let response = NodeSignal(data)
|
||||
if self.view.currentAccount.account != nil:
|
||||
self.view.setLastLoginResponse(response.event)
|
||||
|
|
|
@ -18,6 +18,7 @@ QtObject:
|
|||
status: Status
|
||||
accounts: seq[NodeAccount]
|
||||
currentAccount*: AccountInfoView
|
||||
isCurrentFlow*: bool
|
||||
|
||||
proc setup(self: LoginView) =
|
||||
self.QAbstractListModel.setup
|
||||
|
@ -32,6 +33,7 @@ QtObject:
|
|||
result.accounts = @[]
|
||||
result.currentAccount = newAccountInfoView()
|
||||
result.status = status
|
||||
result.isCurrentFlow = false
|
||||
result.setup
|
||||
|
||||
proc getCurrentAccount*(self: LoginView): QVariant {.slot.} =
|
||||
|
@ -101,3 +103,20 @@ QtObject:
|
|||
self.loginResponseChanged(loginResponse.error)
|
||||
|
||||
proc onLoggedOut*(self: LoginView) {.signal.}
|
||||
|
||||
proc isCurrentFlow*(self: LoginView): bool {.slot.} =
|
||||
result = self.isCurrentFlow
|
||||
|
||||
proc currentFlowChanged*(self: LoginView, v: bool) {.signal.}
|
||||
|
||||
proc setCurrentFlow*(self: LoginView, v: bool) {.slot.} =
|
||||
if self.isCurrentFlow == v: return
|
||||
self.isCurrentFlow = v
|
||||
self.currentFlowChanged(v)
|
||||
|
||||
proc `isCurrentFlow=`*(self: LoginView, v: bool) = self.setCurrentFlow(v)
|
||||
|
||||
QtProperty[bool] isCurrentFlow:
|
||||
read = isCurrentFlow
|
||||
write = setCurrentFlow
|
||||
notify = currentFlowChanged
|
||||
|
|
|
@ -30,6 +30,7 @@ proc reset*(self: OnboardingController) =
|
|||
self.view.removeAccounts()
|
||||
|
||||
proc handleNodeLogin(self: OnboardingController, data: Signal) =
|
||||
if not self.view.isCurrentFlow: return
|
||||
let response = NodeSignal(data)
|
||||
if self.view.currentAccount.account != nil:
|
||||
self.view.setLastLoginResponse(response.event)
|
||||
|
|
|
@ -16,6 +16,7 @@ QtObject:
|
|||
accounts*: seq[GeneratedAccount]
|
||||
currentAccount*: AccountInfoView
|
||||
status*: Status
|
||||
isCurrentFlow*: bool
|
||||
|
||||
proc setup(self: OnboardingView) =
|
||||
self.QAbstractListModel.setup
|
||||
|
@ -30,6 +31,7 @@ QtObject:
|
|||
result.accounts = @[]
|
||||
result.currentAccount = newAccountInfoView()
|
||||
result.status = status
|
||||
result.isCurrentFlow = false
|
||||
result.setup
|
||||
|
||||
proc addAccountToList*(self: OnboardingView, account: GeneratedAccount) =
|
||||
|
@ -106,3 +108,20 @@ QtObject:
|
|||
|
||||
proc setLastLoginResponse*(self: OnboardingView, loginResponse: StatusGoError) =
|
||||
self.loginResponseChanged(loginResponse.error)
|
||||
|
||||
proc isCurrentFlow*(self: OnboardingView): bool {.slot.} =
|
||||
result = self.isCurrentFlow
|
||||
|
||||
proc currentFlowChanged*(self: OnboardingView, v: bool) {.signal.}
|
||||
|
||||
proc setCurrentFlow*(self: OnboardingView, v: bool) {.slot.} =
|
||||
if self.isCurrentFlow == v: return
|
||||
self.isCurrentFlow = v
|
||||
self.currentFlowChanged(v)
|
||||
|
||||
proc `isCurrentFlow=`*(self: OnboardingView, v: bool) = self.setCurrentFlow(v)
|
||||
|
||||
QtProperty[bool] isCurrentFlow:
|
||||
read = isCurrentFlow
|
||||
write = setCurrentFlow
|
||||
notify = currentFlowChanged
|
||||
|
|
|
@ -155,6 +155,8 @@ ModalPopup {
|
|||
}
|
||||
// TODO this doesn't seem to work because the function freezes the view
|
||||
loading = true
|
||||
loginModel.isCurrentFlow = false;
|
||||
onboardingModel.isCurrentFlow = true;
|
||||
const result = onboardingModel.storeDerivedAndLogin(repeatPasswordField.text);
|
||||
const error = JSON.parse(result).error
|
||||
if (error) {
|
||||
|
|
|
@ -15,6 +15,11 @@ Item {
|
|||
id: loginView
|
||||
anchors.fill: parent
|
||||
|
||||
function setCurrentFlow(isLogin) {
|
||||
loginModel.isCurrentFlow = isLogin;
|
||||
onboardingModel.isCurrentFlow = !isLogin;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
txtPassword.forceActiveFocus(Qt.MouseFocusReason)
|
||||
}
|
||||
|
@ -46,6 +51,7 @@ Item {
|
|||
ConfirmAddExistingKeyModal {
|
||||
id: confirmAddExstingKeyModal
|
||||
onOpenModalClick: function () {
|
||||
setCurrentFlow(false);
|
||||
onExistingKeyClicked()
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +62,7 @@ Item {
|
|||
loginModel.setCurrentAccount(index)
|
||||
}
|
||||
onOpenModalClick: function () {
|
||||
setCurrentFlow(true);
|
||||
confirmAddExstingKeyModal.open()
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +150,7 @@ Item {
|
|||
if (loading) {
|
||||
return;
|
||||
}
|
||||
setCurrentFlow(true);
|
||||
loading = true
|
||||
loginModel.login(txtPassword.textField.text)
|
||||
}
|
||||
|
@ -222,6 +230,7 @@ Item {
|
|||
anchors.topMargin: 26
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: {
|
||||
setCurrentFlow(false);
|
||||
onGenKeyClicked()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue