fix: determine if a mnemonic has been loaded only once

This commit is contained in:
Richard Ramos 2021-01-19 12:47:45 -04:00 committed by Iuri Matias
parent f77b27854d
commit 6af10ac900
1 changed files with 6 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import NimQml, chronicles, strutils
import ../../../status/status import ../../../status/status
import ../../../status/libstatus/settings as status_settings import ../../../status/libstatus/settings as status_settings
import ../../../status/libstatus/types import ../../../status/libstatus/types
import options
logScope: logScope:
topics = "mnemonic-view" topics = "mnemonic-view"
@ -9,6 +10,7 @@ logScope:
QtObject: QtObject:
type MnemonicView* = ref object of QObject type MnemonicView* = ref object of QObject
status: Status status: Status
isMnemonicBackedUp: Option[bool]
proc setup(self: MnemonicView) = proc setup(self: MnemonicView) =
self.QObject.setup self.QObject.setup
@ -22,8 +24,9 @@ QtObject:
result.setup result.setup
proc isBackedUp*(self: MnemonicView): bool {.slot.} = proc isBackedUp*(self: MnemonicView): bool {.slot.} =
let mnemonic = status_settings.getSetting[string](Setting.Mnemonic, "") if self.isMnemonicBackedUp.isNone:
return mnemonic == "" self.isMnemonicBackedUp = some(status_settings.getSetting[string](Setting.Mnemonic, "") == "")
self.isMnemonicBackedUp.get()
proc seedPhraseRemoved*(self: MnemonicView) {.signal.} proc seedPhraseRemoved*(self: MnemonicView) {.signal.}
@ -42,6 +45,7 @@ QtObject:
proc remove*(self: MnemonicView) {.slot.} = proc remove*(self: MnemonicView) {.slot.} =
discard status_settings.saveSetting(Setting.Mnemonic, "") discard status_settings.saveSetting(Setting.Mnemonic, "")
self.isMnemonicBackedUp = some(true)
self.seedPhraseRemoved() self.seedPhraseRemoved()
proc getWord*(self: MnemonicView, idx: int): string {.slot.} = proc getWord*(self: MnemonicView, idx: int): string {.slot.} =