mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-20 11:29:20 +00:00
4ec593baed
Move the onboarding/login state machine to the top level in main.qml, so that logout events can trigger new states. Add Loader to statemachine so that each component is lazy-loaded. Initial tests saved 50MB of memory on startup. Currently, logging out, then logging back in to the same or different account results in a doubling-up of chats/messages/wallet accounts. These need to be reset, however I need help doing that and it would delayed and blown out this PR further. This reset has been done for Onboarding and Login, but needs to be done for chats, wallet, mailservers, etc.
52 lines
1.4 KiB
Nim
52 lines
1.4 KiB
Nim
import eventemitter
|
|
|
|
import libstatus/types
|
|
import libstatus/accounts as libstatus_accounts
|
|
import libstatus/core as libstatus_core
|
|
|
|
import chat as chat
|
|
import accounts as accounts
|
|
import wallet as wallet
|
|
import node as node
|
|
import mailservers as mailservers
|
|
import profile
|
|
import ../signals/types as signal_types
|
|
|
|
type Status* = ref object
|
|
events*: EventEmitter
|
|
chat*: ChatModel
|
|
mailservers*: MailserverModel
|
|
accounts*: AccountModel
|
|
wallet*: WalletModel
|
|
node*: NodeModel
|
|
profile*: ProfileModel
|
|
|
|
proc newStatusInstance*(): Status =
|
|
result = Status()
|
|
result.events = createEventEmitter()
|
|
result.chat = chat.newChatModel(result.events)
|
|
result.accounts = accounts.newAccountModel(result.events)
|
|
result.wallet = wallet.newWalletModel(result.events)
|
|
result.wallet.initEvents()
|
|
result.node = node.newNodeModel()
|
|
result.mailservers = mailservers.newMailserverModel(result.events)
|
|
result.profile = profile.newProfileModel()
|
|
|
|
proc initNode*(self: Status) =
|
|
libstatus_accounts.initNode()
|
|
|
|
proc startMessenger*(self: Status) =
|
|
libstatus_core.startMessenger()
|
|
|
|
proc reset*(self: Status) =
|
|
# TODO: remove this once accounts are not tracked in the AccountsModel
|
|
self.accounts.reset()
|
|
|
|
# NOT NEEDED self.chat.reset()
|
|
# NOT NEEDED self.wallet.reset()
|
|
# NOT NEEDED self.node.reset()
|
|
# NOT NEEDED self.mailservers.reset()
|
|
# NOT NEEDED self.profile.reset()
|
|
|
|
# TODO: add all resets here
|