refactor: signal handling

This commit is contained in:
Richard Ramos 2021-09-08 16:27:18 -04:00 committed by Iuri Matias
parent 6514eb6c5c
commit d32c3e53d9
16 changed files with 17 additions and 50 deletions

View File

@ -4,7 +4,6 @@ import status/messages as messages_model
import status/[chat, contacts, status, wallet, stickers, settings]
import status/types/[message, transaction, os_notification, setting]
import ../../app_service/[main]
import status/signals/[base]
import view, views/channels_list, views/message_list, views/reactions, views/stickers as stickers_view
import eventemitter

View File

@ -1,7 +1,6 @@
import
../../app_service/tasks/marathon/mailserver/worker,
status/signals/messages as signals_messages,
status/signals/[community, discovery_summary, envelope, expired]
status/signals
proc handleSignals(self: ChatController) =
self.status.events.on(SignalType.Message.event) do(e:Args):

View File

@ -13,7 +13,6 @@ import status/types/[activity_center_notification, os_notification, rpc_response
import ../../app_service/[main]
import ../../app_service/tasks/[qt, threadpool]
import ../../app_service/tasks/marathon/mailserver/worker
import status/signals/[base]
import status/notifications/[os_notifications]
import ../utils/image_utils
import web3/[conversions, ethtypes]

View File

@ -6,7 +6,6 @@ import ./community_item
import ./community_membership_request_list
import ../../utils/image_utils
import status/types/[activity_center_notification, status_update, rpc_response]
import status/signals/[base]
logScope:
topics = "communities-view"

View File

@ -1,7 +1,6 @@
import NimQml, chronicles, options, std/wrapnils
import status/status
import status/[signals, status]
import status/types/[account, rpc_response]
import status/signals/[base]
import view
import eventemitter

View File

@ -1,7 +1,6 @@
import NimQml, Tables, json, nimcrypto, strformat, json_serialization, chronicles
import status/accounts as AccountModel
import status/types/[account, rpc_response]
import status/signals/[base]
import ../onboarding/views/account_info
import status/status

View File

@ -1,7 +1,6 @@
import NimQml, chronicles
import status/[status, node, network]
import status/[signals, status, node, network]
import ../../app_service/[main]
import status/signals/[base, wallet, discovery_summary, stats]
import eventemitter
import view

View File

@ -1,8 +1,7 @@
import NimQml, chronicles, std/wrapnils
import status/accounts as AccountModel
import status/status
import status/[signals, status]
import status/types/[account]
import status/signals/[base]
import eventemitter
import view

View File

@ -2,7 +2,6 @@ import NimQml, Tables, json, nimcrypto, strformat, json_serialization, strutils
import status/accounts as AccountModel
import status/[status, wallet]
import status/types/[account, rpc_response]
import status/signals/[base]
import views/account_info
type

View File

@ -1,7 +1,7 @@
import NimQml, json, strutils, sugar, sequtils, tables
import json_serialization
import status/profile/[profile, mailserver]
import status/[status, settings]
import status/[status, signals, settings]
import status/contacts as status_contacts
import status/chat as status_chat
import status/devices as status_devices
@ -9,7 +9,6 @@ import status/chat/chat
import status/wallet
import status/types/[account, transaction, setting]
import ../../app_service/[main]
import status/signals/[base, messages]
import ../../app_service/tasks/marathon/mailserver/events
import eventemitter
import view

View File

@ -6,9 +6,8 @@ import views/[asset_list, account_list, account_item]
import status/[status, wallet, settings]
import status/wallet/account as WalletTypes
import status/types/[transaction, setting]
import status/signals
import ../../../app_service/[main]
import status/signals/[base]
import status/signals/wallet as wallet_signal
import eventemitter
logScope:

View File

@ -3,8 +3,7 @@ import NimQml, json, sequtils, chronicles, strutils, strformat, json
import
status/[status, settings],
status/wallet as status_wallet,
status/types/[rpc_response],
status/signals/[base]
status/types/[rpc_response]
import account_list, account_item

View File

@ -7,8 +7,7 @@ import status/[status, wallet2, settings]
import status/wallet2/account as WalletTypes
import status/types/[transaction, setting]
import ../../../app_service/[main]
import status/signals/[base]
import status/signals/wallet as wallet_signal
import status/signals
import eventemitter
logScope:

View File

@ -3,8 +3,7 @@ import NimQml, json, sequtils, chronicles, strutils, strformat, json
import
status/[status, settings],
status/wallet2 as status_wallet,
status/types/[rpc_response],
status/signals/[base]
status/types/[rpc_response]
import account_list, account_item

View File

@ -1,6 +1,5 @@
import NimQml, json, chronicles, strutils, json_serialization
import status/signals/[base, signal_type, messages, discovery_summary, whisper_filter, envelope, expired,
wallet, mailserver, community, stats]
import status/signals
import status/status
import eventemitter
@ -33,41 +32,23 @@ QtObject:
error "Invalid signal received", data = statusSignal
return
let signalString = jsonSignal["type"].getStr
trace "Raw signal data", data = $jsonSignal
var signalType: SignalType
var signal:Signal
try:
signalType = parseEnum[SignalType](signalString)
signal = decode(jsonSignal)
except:
warn "Unknown signal received", type = signalString
signalType = SignalType.Unknown
warn "Error decoding signal", err=getCurrentExceptionMsg()
return
var signal: Signal = case signalType:
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(signal.signalType == SignalType.NodeLogin):
if(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
self.status.events.emit(signalType.event, signal)
self.status.events.emit(signal.signalType.event, signal)
proc signalReceived*(self: SignalsController, signal: string) {.signal.}

@ -1 +1 @@
Subproject commit 0b24d7a341dadcfdf59c6dbbb93506b6bb20bf66
Subproject commit a044a941e671b66bb55dd127daa2d97a1f1d0535