refactor: Use status object
This commit is contained in:
parent
4670bd57c4
commit
31b0207dcc
|
@ -41,17 +41,17 @@ proc handleChatEvents(self: ChatController) =
|
|||
let chatItem = newChatItem(id = channelMessage.channel, channelMessage.chatTypeInt)
|
||||
discard self.view.chats.addChatItemToList(chatItem)
|
||||
|
||||
self.chatModel.events.on("channelLeft") do(e: Args):
|
||||
self.status.events.on("channelLeft") do(e: Args):
|
||||
discard self.view.chats.removeChatItemFromList(self.view.activeChannel)
|
||||
|
||||
self.chatModel.events.on("activeChannelChanged") do(e: Args):
|
||||
self.status.events.on("activeChannelChanged") do(e: Args):
|
||||
self.view.setActiveChannel(ChannelArgs(e).channel)
|
||||
|
||||
proc init*(self: ChatController) =
|
||||
self.handleChatEvents()
|
||||
|
||||
self.chatModel.init()
|
||||
self.mailserverModel.init()
|
||||
self.status.chat.init()
|
||||
self.status.mailservers.init()
|
||||
|
||||
self.view.setActiveChannelByIndex(0)
|
||||
|
||||
|
@ -68,7 +68,7 @@ proc handleMessage(self: ChatController, data: Signal) =
|
|||
|
||||
proc handleDiscoverySummary(self: ChatController, data: Signal) =
|
||||
var discovery = DiscoverySummarySignal(data)
|
||||
self.mailserverModel.peerSummaryChange(discovery.enodes)
|
||||
self.status.mailservers.peerSummaryChange(discovery.enodes)
|
||||
|
||||
method onSignal(self: ChatController, data: Signal) =
|
||||
case data.signalType:
|
||||
|
|
|
@ -32,9 +32,9 @@ proc cmpMailserverReply(x, y: (string, int)): int =
|
|||
|
||||
proc poolSize(fleetSize: int): int = ceil(fleetSize / 4).int
|
||||
|
||||
proc newMailserverModel*(): MailserverModel =
|
||||
proc newMailserverModel*(events: EventEmitter): MailserverModel =
|
||||
result = MailserverModel()
|
||||
result.events = createEventEmitter()
|
||||
result.events = events
|
||||
result.nodes = initTable[string, MailserverStatus]()
|
||||
|
||||
proc trustPeer*(self: MailserverModel, enode:string) =
|
||||
|
|
|
@ -8,10 +8,12 @@ import chat as chat
|
|||
import accounts as accounts
|
||||
import wallet as wallet
|
||||
import node as node
|
||||
import mailservers as mailservers
|
||||
|
||||
type Status* = ref object
|
||||
events*: EventEmitter
|
||||
chat*: ChatModel
|
||||
mailservers*: MailserverModel
|
||||
accounts*: AccountModel
|
||||
wallet*: WalletModel
|
||||
node*: NodeModel
|
||||
|
@ -23,6 +25,7 @@ proc newStatusInstance*(): Status =
|
|||
result.accounts = accounts.newAccountModel()
|
||||
result.wallet = wallet.newWalletModel()
|
||||
result.node = node.newNodeModel()
|
||||
result.mailservers = mailservers.newMailserverModel(result.events)
|
||||
|
||||
proc initNodeAccounts*(self: Status): seq[NodeAccount] =
|
||||
libstatus_accounts.initNodeAccounts()
|
||||
|
|
Loading…
Reference in New Issue