separate model events from app events
This commit is contained in:
parent
d434af40e1
commit
8a0a5a2e60
|
@ -20,9 +20,11 @@ type OnboardingController* = ref object of SignalSubscriber
|
||||||
proc newController*(events: EventEmitter): OnboardingController =
|
proc newController*(events: EventEmitter): OnboardingController =
|
||||||
result = OnboardingController()
|
result = OnboardingController()
|
||||||
# TODO: events should be specific to the model itself
|
# TODO: events should be specific to the model itself
|
||||||
result.model = newAccountModel(events)
|
result.model = newAccountModel()
|
||||||
result.view = newOnboardingView(result.model)
|
result.view = newOnboardingView(result.model)
|
||||||
result.variant = newQVariant(result.view)
|
result.variant = newQVariant(result.view)
|
||||||
|
result.model.events.on("accountsReady") do(a: Args):
|
||||||
|
events.emit("node:ready", Args())
|
||||||
|
|
||||||
proc delete*(self: OnboardingController) =
|
proc delete*(self: OnboardingController) =
|
||||||
delete self.view
|
delete self.view
|
||||||
|
|
|
@ -30,9 +30,9 @@ type
|
||||||
generatedAddresses*: seq[GeneratedAccount]
|
generatedAddresses*: seq[GeneratedAccount]
|
||||||
events*: EventEmitter
|
events*: EventEmitter
|
||||||
|
|
||||||
proc newAccountModel*(events: EventEmitter): AccountModel =
|
proc newAccountModel*(): AccountModel =
|
||||||
result = AccountModel()
|
result = AccountModel()
|
||||||
result.events = events
|
result.events = createEventEmitter()
|
||||||
result.generatedAddresses = @[]
|
result.generatedAddresses = @[]
|
||||||
|
|
||||||
proc delete*(self: AccountModel) =
|
proc delete*(self: AccountModel) =
|
||||||
|
@ -65,7 +65,7 @@ proc generateAddresses*(self: AccountModel): seq[GeneratedAccount] =
|
||||||
# TODO: this is temporary and will be removed once accounts import and creation is working
|
# TODO: this is temporary and will be removed once accounts import and creation is working
|
||||||
proc generateRandomAccountAndLogin*(self: AccountModel) =
|
proc generateRandomAccountAndLogin*(self: AccountModel) =
|
||||||
discard status_test.setupNewAccount()
|
discard status_test.setupNewAccount()
|
||||||
self.events.emit("node:ready", Args())
|
self.events.emit("accountsReady", Args())
|
||||||
|
|
||||||
proc storeAccountAndLogin*(self: AccountModel, selectedAccountIndex: int, password: string): string =
|
proc storeAccountAndLogin*(self: AccountModel, selectedAccountIndex: int, password: string): string =
|
||||||
# let account = to(json.parseJson(selectedAccount), Models.GeneratedAccount)
|
# let account = to(json.parseJson(selectedAccount), Models.GeneratedAccount)
|
||||||
|
@ -146,5 +146,5 @@ proc storeAccountAndLogin*(self: AccountModel, selectedAccountIndex: int, passwo
|
||||||
let saveResult = result.parseJson
|
let saveResult = result.parseJson
|
||||||
|
|
||||||
if saveResult["error"].getStr == "":
|
if saveResult["error"].getStr == "":
|
||||||
self.events.emit("node:ready", Args())
|
self.events.emit("accountsReady", Args())
|
||||||
echo "Account saved succesfully"
|
echo "Account saved succesfully"
|
||||||
|
|
Loading…
Reference in New Issue