refactor: use service defined signals instead of SignalType

This commit is contained in:
Patryk Osmaczko 2022-12-16 15:59:36 +01:00 committed by osmaczko
parent 9ce9598a83
commit bf324f273a
2 changed files with 6 additions and 5 deletions

View File

@ -233,15 +233,12 @@ proc init*(self: Controller) =
let args = ContactsStatusUpdatedArgs(e)
self.delegate.contactsStatusUpdated(args.statusUpdates)
self.events.on(SignalType.HistoryRequestStarted.event) do(e: Args):
self.events.on(SIGNAL_MAILSERVER_HISTORY_REQUEST_STARTED) do(e: Args):
self.delegate.setLoadingHistoryMessagesInProgress(true)
self.events.on(SignalType.HistoryRequestCompleted.event) do(e:Args):
self.events.on(SIGNAL_MAILSERVER_HISTORY_REQUEST_COMPLETED) do(e:Args):
self.delegate.setLoadingHistoryMessagesInProgress(false)
self.events.on(SignalType.HistoryRequestFailed.event) do(e:Args):
discard
proc getMySectionId*(self: Controller): string =
return self.sectionId

View File

@ -42,6 +42,8 @@ const SIGNAL_ACTIVE_MAILSERVER_CHANGED* = "activeMailserverChanged"
const SIGNAL_MAILSERVER_AVAILABLE* = "mailserverAvailable"
const SIGNAL_MAILSERVER_NOT_WORKING* = "mailserverNotWorking"
const SIGNAL_MAILSERVER_SYNCED* = "mailserverSynced"
const SIGNAL_MAILSERVER_HISTORY_REQUEST_STARTED* = "historyRequestStarted"
const SIGNAL_MAILSERVER_HISTORY_REQUEST_COMPLETED* = "historyRequestCompleted"
const requestMoreMessagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[RequestMoreMessagesTaskArg](argEncoded)
@ -171,10 +173,12 @@ QtObject:
self.events.on(SignalType.HistoryRequestStarted.event) do(e: Args):
let h = HistoryRequestStartedSignal(e)
info "history request started", numBatches=h.numBatches
self.events.emit(SIGNAL_MAILSERVER_HISTORY_REQUEST_STARTED, Args())
self.events.on(SignalType.HistoryRequestCompleted.event) do(e: Args):
let h = HistoryRequestCompletedSignal(e)
info "history request completed"
self.events.emit(SIGNAL_MAILSERVER_HISTORY_REQUEST_COMPLETED, Args())
self.events.on(SignalType.HistoryRequestFailed.event) do(e: Args):
let h = HistoryRequestFailedSignal(e)