move generateRandomAccountAndLogin out of view

This commit is contained in:
Iuri Matias 2020-05-20 15:40:37 -04:00
parent 2cf1541115
commit 23f72c77bc
2 changed files with 9 additions and 9 deletions

View File

@ -14,11 +14,6 @@ import eventemitter
import view
proc storeAccountAndLogin(events: EventEmitter, selectedAccount: string, password: string): string =
echo "--------------------"
echo "--------------------"
echo "storeAccountAndLogin"
echo "--------------------"
echo "--------------------"
let account = to(json.parseJson(selectedAccount), Models.GeneratedAccount)
let password = "0x" & $keccak_256.digest(password)
let multiAccount = %* {
@ -94,13 +89,17 @@ proc storeAccountAndLogin(events: EventEmitter, selectedAccount: string, passwor
events.emit("node:ready", Args())
echo "Account saved succesfully"
proc generateRandomAccountAndLogin*(events: EventEmitter) =
discard status_test.setupNewAccount()
events.emit("node:ready", Args())
type OnboardingController* = ref object of SignalSubscriber
view*: OnboardingView
variant*: QVariant
proc newController*(events: EventEmitter): OnboardingController =
result = OnboardingController()
result.view = newOnboardingView(events, storeAccountAndLogin)
result.view = newOnboardingView(events, storeAccountAndLogin, generateRandomAccountAndLogin)
result.variant = newQVariant(result.view)
proc delete*(self: OnboardingController) =

View File

@ -15,6 +15,7 @@ QtObject:
m_generatedAddresses: string
events: EventEmitter
doStoreAccountAndLogin: proc(events: EventEmitter, selectedAccount: string, password: string): string
doGenerateRandomAccountAndLogin: proc(events: EventEmitter)
proc setup(self: OnboardingView) =
self.QObject.setup
@ -22,10 +23,11 @@ QtObject:
proc delete*(self: OnboardingView) =
self.QObject.delete
proc newOnboardingView*(events: EventEmitter, doStoreAccountAndLogin: proc): OnboardingView =
proc newOnboardingView*(events: EventEmitter, doStoreAccountAndLogin: proc, doGenerateRandomAccountAndLogin: proc(events: EventEmitter)): OnboardingView =
new(result, delete)
result.events = events
result.doStoreAccountAndLogin = doStoreAccountAndLogin
result.doGenerateRandomAccountAndLogin = doGenerateRandomAccountAndLogin
result.setup()
proc getGeneratedAddresses*(self: OnboardingView): string {.slot.} =
@ -59,5 +61,4 @@ QtObject:
result = self.doStoreAccountAndLogin(self.events, selectedAccount, password)
proc generateRandomAccountAndLogin*(self: OnboardingView) {.slot.} =
discard status_test.setupNewAccount()
self.events.emit("node:ready", Args())
self.doGenerateRandomAccountAndLogin(self.events)