refactor: signal handling
This commit is contained in:
parent
6514eb6c5c
commit
d32c3e53d9
|
@ -4,7 +4,6 @@ import status/messages as messages_model
|
||||||
import status/[chat, contacts, status, wallet, stickers, settings]
|
import status/[chat, contacts, status, wallet, stickers, settings]
|
||||||
import status/types/[message, transaction, os_notification, setting]
|
import status/types/[message, transaction, os_notification, setting]
|
||||||
import ../../app_service/[main]
|
import ../../app_service/[main]
|
||||||
import status/signals/[base]
|
|
||||||
import view, views/channels_list, views/message_list, views/reactions, views/stickers as stickers_view
|
import view, views/channels_list, views/message_list, views/reactions, views/stickers as stickers_view
|
||||||
import eventemitter
|
import eventemitter
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import
|
import
|
||||||
../../app_service/tasks/marathon/mailserver/worker,
|
../../app_service/tasks/marathon/mailserver/worker,
|
||||||
status/signals/messages as signals_messages,
|
status/signals
|
||||||
status/signals/[community, discovery_summary, envelope, expired]
|
|
||||||
|
|
||||||
proc handleSignals(self: ChatController) =
|
proc handleSignals(self: ChatController) =
|
||||||
self.status.events.on(SignalType.Message.event) do(e:Args):
|
self.status.events.on(SignalType.Message.event) do(e:Args):
|
||||||
|
|
|
@ -13,7 +13,6 @@ import status/types/[activity_center_notification, os_notification, rpc_response
|
||||||
import ../../app_service/[main]
|
import ../../app_service/[main]
|
||||||
import ../../app_service/tasks/[qt, threadpool]
|
import ../../app_service/tasks/[qt, threadpool]
|
||||||
import ../../app_service/tasks/marathon/mailserver/worker
|
import ../../app_service/tasks/marathon/mailserver/worker
|
||||||
import status/signals/[base]
|
|
||||||
import status/notifications/[os_notifications]
|
import status/notifications/[os_notifications]
|
||||||
import ../utils/image_utils
|
import ../utils/image_utils
|
||||||
import web3/[conversions, ethtypes]
|
import web3/[conversions, ethtypes]
|
||||||
|
|
|
@ -6,7 +6,6 @@ import ./community_item
|
||||||
import ./community_membership_request_list
|
import ./community_membership_request_list
|
||||||
import ../../utils/image_utils
|
import ../../utils/image_utils
|
||||||
import status/types/[activity_center_notification, status_update, rpc_response]
|
import status/types/[activity_center_notification, status_update, rpc_response]
|
||||||
import status/signals/[base]
|
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "communities-view"
|
topics = "communities-view"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import NimQml, chronicles, options, std/wrapnils
|
import NimQml, chronicles, options, std/wrapnils
|
||||||
import status/status
|
import status/[signals, status]
|
||||||
import status/types/[account, rpc_response]
|
import status/types/[account, rpc_response]
|
||||||
import status/signals/[base]
|
|
||||||
import view
|
import view
|
||||||
import eventemitter
|
import eventemitter
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import NimQml, Tables, json, nimcrypto, strformat, json_serialization, chronicles
|
import NimQml, Tables, json, nimcrypto, strformat, json_serialization, chronicles
|
||||||
import status/accounts as AccountModel
|
import status/accounts as AccountModel
|
||||||
import status/types/[account, rpc_response]
|
import status/types/[account, rpc_response]
|
||||||
import status/signals/[base]
|
|
||||||
import ../onboarding/views/account_info
|
import ../onboarding/views/account_info
|
||||||
import status/status
|
import status/status
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import NimQml, chronicles
|
import NimQml, chronicles
|
||||||
import status/[status, node, network]
|
import status/[signals, status, node, network]
|
||||||
import ../../app_service/[main]
|
import ../../app_service/[main]
|
||||||
import status/signals/[base, wallet, discovery_summary, stats]
|
|
||||||
import eventemitter
|
import eventemitter
|
||||||
import view
|
import view
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import NimQml, chronicles, std/wrapnils
|
import NimQml, chronicles, std/wrapnils
|
||||||
import status/accounts as AccountModel
|
import status/accounts as AccountModel
|
||||||
import status/status
|
import status/[signals, status]
|
||||||
import status/types/[account]
|
import status/types/[account]
|
||||||
import status/signals/[base]
|
|
||||||
import eventemitter
|
import eventemitter
|
||||||
import view
|
import view
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import NimQml, Tables, json, nimcrypto, strformat, json_serialization, strutils
|
||||||
import status/accounts as AccountModel
|
import status/accounts as AccountModel
|
||||||
import status/[status, wallet]
|
import status/[status, wallet]
|
||||||
import status/types/[account, rpc_response]
|
import status/types/[account, rpc_response]
|
||||||
import status/signals/[base]
|
|
||||||
import views/account_info
|
import views/account_info
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import NimQml, json, strutils, sugar, sequtils, tables
|
import NimQml, json, strutils, sugar, sequtils, tables
|
||||||
import json_serialization
|
import json_serialization
|
||||||
import status/profile/[profile, mailserver]
|
import status/profile/[profile, mailserver]
|
||||||
import status/[status, settings]
|
import status/[status, signals, settings]
|
||||||
import status/contacts as status_contacts
|
import status/contacts as status_contacts
|
||||||
import status/chat as status_chat
|
import status/chat as status_chat
|
||||||
import status/devices as status_devices
|
import status/devices as status_devices
|
||||||
|
@ -9,7 +9,6 @@ import status/chat/chat
|
||||||
import status/wallet
|
import status/wallet
|
||||||
import status/types/[account, transaction, setting]
|
import status/types/[account, transaction, setting]
|
||||||
import ../../app_service/[main]
|
import ../../app_service/[main]
|
||||||
import status/signals/[base, messages]
|
|
||||||
import ../../app_service/tasks/marathon/mailserver/events
|
import ../../app_service/tasks/marathon/mailserver/events
|
||||||
import eventemitter
|
import eventemitter
|
||||||
import view
|
import view
|
||||||
|
|
|
@ -6,9 +6,8 @@ import views/[asset_list, account_list, account_item]
|
||||||
import status/[status, wallet, settings]
|
import status/[status, wallet, settings]
|
||||||
import status/wallet/account as WalletTypes
|
import status/wallet/account as WalletTypes
|
||||||
import status/types/[transaction, setting]
|
import status/types/[transaction, setting]
|
||||||
|
import status/signals
|
||||||
import ../../../app_service/[main]
|
import ../../../app_service/[main]
|
||||||
import status/signals/[base]
|
|
||||||
import status/signals/wallet as wallet_signal
|
|
||||||
import eventemitter
|
import eventemitter
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
|
|
|
@ -3,8 +3,7 @@ import NimQml, json, sequtils, chronicles, strutils, strformat, json
|
||||||
import
|
import
|
||||||
status/[status, settings],
|
status/[status, settings],
|
||||||
status/wallet as status_wallet,
|
status/wallet as status_wallet,
|
||||||
status/types/[rpc_response],
|
status/types/[rpc_response]
|
||||||
status/signals/[base]
|
|
||||||
|
|
||||||
import account_list, account_item
|
import account_list, account_item
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@ import status/[status, wallet2, settings]
|
||||||
import status/wallet2/account as WalletTypes
|
import status/wallet2/account as WalletTypes
|
||||||
import status/types/[transaction, setting]
|
import status/types/[transaction, setting]
|
||||||
import ../../../app_service/[main]
|
import ../../../app_service/[main]
|
||||||
import status/signals/[base]
|
import status/signals
|
||||||
import status/signals/wallet as wallet_signal
|
|
||||||
import eventemitter
|
import eventemitter
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
|
|
|
@ -3,8 +3,7 @@ import NimQml, json, sequtils, chronicles, strutils, strformat, json
|
||||||
import
|
import
|
||||||
status/[status, settings],
|
status/[status, settings],
|
||||||
status/wallet2 as status_wallet,
|
status/wallet2 as status_wallet,
|
||||||
status/types/[rpc_response],
|
status/types/[rpc_response]
|
||||||
status/signals/[base]
|
|
||||||
|
|
||||||
import account_list, account_item
|
import account_list, account_item
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import NimQml, json, chronicles, strutils, json_serialization
|
import NimQml, json, chronicles, strutils, json_serialization
|
||||||
import status/signals/[base, signal_type, messages, discovery_summary, whisper_filter, envelope, expired,
|
import status/signals
|
||||||
wallet, mailserver, community, stats]
|
|
||||||
import status/status
|
import status/status
|
||||||
import eventemitter
|
import eventemitter
|
||||||
|
|
||||||
|
@ -33,41 +32,23 @@ QtObject:
|
||||||
error "Invalid signal received", data = statusSignal
|
error "Invalid signal received", data = statusSignal
|
||||||
return
|
return
|
||||||
|
|
||||||
let signalString = jsonSignal["type"].getStr
|
|
||||||
|
|
||||||
trace "Raw signal data", data = $jsonSignal
|
trace "Raw signal data", data = $jsonSignal
|
||||||
|
|
||||||
var signalType: SignalType
|
var signal:Signal
|
||||||
|
|
||||||
try:
|
try:
|
||||||
signalType = parseEnum[SignalType](signalString)
|
signal = decode(jsonSignal)
|
||||||
except:
|
except:
|
||||||
warn "Unknown signal received", type = signalString
|
warn "Error decoding signal", err=getCurrentExceptionMsg()
|
||||||
signalType = SignalType.Unknown
|
|
||||||
return
|
return
|
||||||
|
|
||||||
var signal: Signal = case signalType:
|
if(signal.signalType == SignalType.NodeLogin):
|
||||||
of SignalType.Message: messages.fromEvent(jsonSignal)
|
|
||||||
of SignalType.EnvelopeSent: envelope.fromEvent(jsonSignal)
|
|
||||||
of SignalType.EnvelopeExpired: expired.fromEvent(jsonSignal)
|
|
||||||
of SignalType.WhisperFilterAdded: whisperFilter.fromEvent(jsonSignal)
|
|
||||||
of SignalType.Wallet: wallet.fromEvent(jsonSignal)
|
|
||||||
of SignalType.NodeLogin: Json.decode($jsonSignal, NodeSignal)
|
|
||||||
of SignalType.DiscoverySummary: discovery_summary.fromEvent(jsonSignal)
|
|
||||||
of SignalType.MailserverRequestCompleted: mailserver.fromCompletedEvent(jsonSignal)
|
|
||||||
of SignalType.MailserverRequestExpired: mailserver.fromExpiredEvent(jsonSignal)
|
|
||||||
of SignalType.CommunityFound: community.fromEvent(jsonSignal)
|
|
||||||
of SignalType.Stats: stats.fromEvent(jsonSignal)
|
|
||||||
else: Signal()
|
|
||||||
|
|
||||||
if(signalType == SignalType.NodeLogin):
|
|
||||||
if(NodeSignal(signal).event.error != ""):
|
if(NodeSignal(signal).event.error != ""):
|
||||||
error "node.login", error=NodeSignal(signal).event.error
|
error "node.login", error=NodeSignal(signal).event.error
|
||||||
|
|
||||||
if(signalType == SignalType.NodeCrashed):
|
if(signal.signalType == SignalType.NodeCrashed):
|
||||||
error "node.crashed", error=statusSignal
|
error "node.crashed", error=statusSignal
|
||||||
|
|
||||||
self.status.events.emit(signalType.event, signal)
|
self.status.events.emit(signal.signalType.event, signal)
|
||||||
|
|
||||||
proc signalReceived*(self: SignalsController, signal: string) {.signal.}
|
proc signalReceived*(self: SignalsController, signal: string) {.signal.}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0b24d7a341dadcfdf59c6dbbb93506b6bb20bf66
|
Subproject commit a044a941e671b66bb55dd127daa2d97a1f1d0535
|
Loading…
Reference in New Issue