pass generated account to profile
This commit is contained in:
parent
656e553a32
commit
4c9a370fc3
|
@ -16,14 +16,15 @@ type OnboardingController* = ref object of SignalSubscriber
|
|||
variant*: QVariant
|
||||
model*: AccountModel
|
||||
|
||||
proc newController*(events: EventEmitter): OnboardingController =
|
||||
proc newController*(events: EventEmitter, model: AccountModel): OnboardingController =
|
||||
result = OnboardingController()
|
||||
# TODO: events should be specific to the model itself
|
||||
result.model = newAccountModel()
|
||||
# result.model = newAccountModel()
|
||||
result.model = model
|
||||
result.view = newOnboardingView(result.model)
|
||||
result.variant = newQVariant(result.view)
|
||||
result.model.events.on("accountsReady") do(a: Args):
|
||||
events.emit("node:ready", Args())
|
||||
# result.model.events.on("accountsReady") do(a: Args):
|
||||
# events.emit("node:ready", Args())
|
||||
|
||||
proc delete*(self: OnboardingController) =
|
||||
delete self.view
|
||||
|
|
|
@ -20,5 +20,5 @@ proc delete*(self: ProfileController) =
|
|||
proc init*(self: ProfileController, accounts: string) =
|
||||
var chatAccount = parseJSON(accounts)[1]
|
||||
|
||||
self.view.username = chatAccount["name"].str
|
||||
self.view.identicon = chatAccount["photo-path"].str
|
||||
self.view.setUsername(chatAccount["name"].str)
|
||||
self.view.setIdenticon(chatAccount["photo-path"].str)
|
||||
|
|
|
@ -22,11 +22,13 @@ type
|
|||
AccountModel* = ref object
|
||||
generatedAddresses*: seq[GeneratedAccount]
|
||||
events*: EventEmitter
|
||||
subaccounts*: JsonNode #TODO use correct account, etc..
|
||||
|
||||
proc newAccountModel*(): AccountModel =
|
||||
result = AccountModel()
|
||||
result.events = createEventEmitter()
|
||||
result.generatedAddresses = @[]
|
||||
result.subaccounts = %*{}
|
||||
|
||||
proc delete*(self: AccountModel) =
|
||||
# delete self.generatedAddresses
|
||||
|
@ -54,10 +56,11 @@ proc generateAddresses*(self: AccountModel): seq[GeneratedAccount] =
|
|||
# TODO: this is temporary and will be removed once accounts import and creation is working
|
||||
proc generateRandomAccountAndLogin*(self: AccountModel) =
|
||||
let generatedAccounts = status_accounts.generateAddresses().parseJson
|
||||
discard status_accounts.setupAccount(generatedAccounts[0], "qwerty")
|
||||
self.subaccounts = status_accounts.setupAccount(generatedAccounts[0], "qwerty").parseJson
|
||||
self.events.emit("accountsReady", Args())
|
||||
|
||||
proc storeAccountAndLogin*(self: AccountModel, selectedAccountIndex: int, password: string): string =
|
||||
let account: GeneratedAccount = self.generatedAddresses[selectedAccountIndex]
|
||||
result = status_accounts.setupAccount(%account, password)
|
||||
self.subaccounts = result.parseJson
|
||||
self.events.emit("accountsReady", Args())
|
||||
|
|
|
@ -19,6 +19,7 @@ import status/chat as status_chat
|
|||
import status/types as types
|
||||
import status/wallet as status_wallet
|
||||
import status/libstatus
|
||||
import models/accounts
|
||||
import state
|
||||
import status/types
|
||||
import eventemitter
|
||||
|
@ -56,12 +57,7 @@ proc mainProc() =
|
|||
# echo "---------"
|
||||
# discard status_test.setupNewAccount()
|
||||
|
||||
events.on("node:ready") do(a: Args):
|
||||
status_chat.startMessenger()
|
||||
|
||||
var wallet = wallet.newController()
|
||||
events.on("node:ready") do(a: Args):
|
||||
wallet.init()
|
||||
engine.setRootContextProperty("assetsModel", wallet.variant)
|
||||
|
||||
var chat = chat.newController()
|
||||
|
@ -70,17 +66,23 @@ proc mainProc() =
|
|||
|
||||
var node = node.newController()
|
||||
node.init()
|
||||
|
||||
engine.setRootContextProperty("nodeModel", node.variant)
|
||||
|
||||
var onboarding = onboarding.newController(events)
|
||||
var profile = profile.newController()
|
||||
engine.setRootContextProperty("profileModel", profile.variant)
|
||||
|
||||
var accountsModel = newAccountModel()
|
||||
# accountsModel.events.on("accountsReady") do(a: Args):
|
||||
# events.on("node:ready") do(a: Args):
|
||||
accountsModel.events.on("accountsReady") do(a: Args):
|
||||
status_chat.startMessenger()
|
||||
wallet.init()
|
||||
profile.init($accountsModel.subaccounts) # TODO: use correct account
|
||||
|
||||
var onboarding = onboarding.newController(events, accountsModel)
|
||||
onboarding.init()
|
||||
engine.setRootContextProperty("onboardingModel", onboarding.variant)
|
||||
|
||||
var profile = profile.newController()
|
||||
# profile.init(accounts) # TODO: use correct account
|
||||
engine.setRootContextProperty("profileModel", profile.variant)
|
||||
|
||||
signalController.init()
|
||||
signalController.addSubscriber(SignalType.Wallet, wallet)
|
||||
signalController.addSubscriber(SignalType.Wallet, node)
|
||||
|
@ -94,7 +96,8 @@ proc mainProc() =
|
|||
chat.join(channel.name)
|
||||
)
|
||||
|
||||
events.on("node:ready") do(a: Args):
|
||||
# events.on("node:ready12313asdada") do(a: Args):
|
||||
accountsModel.events.on("accountsReady") do(a: Args):
|
||||
appState.addChannel("test")
|
||||
appState.addChannel("test2")
|
||||
|
||||
|
|
Loading…
Reference in New Issue