feat: handling `mailserver.not.working` signal

This makes Status Desktop aware of the `mailserver.not.working` signal.
When emitted by status-go, desktop will show a popup that informs the
user about the connection failure.

Furthermore, users can then decide to either retry (same as just closing
the popup as retrying already happens by default), or pick another
pinned mailserver, for which they'll get redirected to the messaging
settings panel.

Closes #5166
This commit is contained in:
Pascal Precht 2022-05-17 16:09:22 +02:00 committed by r4bbit.eth
parent 7c5114cf1d
commit f14717da18
9 changed files with 75 additions and 0 deletions

View File

@ -36,6 +36,8 @@ type MailserverAvailableSignal* = ref object of Signal
type MailserverChangedSignal* = ref object of Signal type MailserverChangedSignal* = ref object of Signal
address*: string address*: string
type MailserverNotWorkingSignal* = ref object of Signal
proc fromEvent*(T: type MailserverRequestCompletedSignal, jsonSignal: JsonNode): MailserverRequestCompletedSignal = proc fromEvent*(T: type MailserverRequestCompletedSignal, jsonSignal: JsonNode): MailserverRequestCompletedSignal =
result = MailserverRequestCompletedSignal() result = MailserverRequestCompletedSignal()
result.signalType = SignalType.MailserverRequestCompleted result.signalType = SignalType.MailserverRequestCompleted
@ -86,3 +88,7 @@ proc fromEvent*(T: type MailserverChangedSignal, jsonSignal: JsonNode): Mailserv
result = MailserverChangedSignal() result = MailserverChangedSignal()
result.signalType = SignalType.MailserverChanged result.signalType = SignalType.MailserverChanged
result.address = jsonSignal["event"]{"address"}.getStr() result.address = jsonSignal["event"]{"address"}.getStr()
proc fromEvent*(T: type MailserverNotWorkingSignal, jsonSignal: JsonNode): MailserverNotWorkingSignal =
result = MailserverNotWorkingSignal()
result.signalType = SignalType.MailseverNotWorking

View File

@ -29,6 +29,7 @@ type SignalType* {.pure.} = enum
KeycardConnected = "keycard.connected" KeycardConnected = "keycard.connected"
MailserverAvailable = "mailserver.available" MailserverAvailable = "mailserver.available"
MailserverChanged = "mailserver.changed" MailserverChanged = "mailserver.changed"
MailserverNotWorking = "mailserver.not.working"
HistoryArchivesProtocolEnabled = "community.historyArchivesProtocolEnabled" HistoryArchivesProtocolEnabled = "community.historyArchivesProtocolEnabled"
HistoryArchivesProtocolDisabled = "community.historyArchivesProtocolDisabled" HistoryArchivesProtocolDisabled = "community.historyArchivesProtocolDisabled"
CreatingHistoryArchives = "community.creatingHistoryArchives" CreatingHistoryArchives = "community.creatingHistoryArchives"

View File

@ -81,6 +81,9 @@ proc init*(self: Controller) =
# requestAllHistoricMessagesResult # requestAllHistoricMessagesResult
# requestMissingCommunityInfos # requestMissingCommunityInfos
self.events.on(SIGNAL_MAILSERVER_NOT_WORKING) do(e: Args):
self.delegate.emitMailserverNotWorking()
if(defined(macosx)): if(defined(macosx)):
let account = self.accountsService.getLoggedInAccount() let account = self.accountsService.getLoggedInAccount()
singletonInstance.localAccountSettings.setFileName(account.name) singletonInstance.localAccountSettings.setFileName(account.name)

View File

@ -90,6 +90,9 @@ method emitStoringPasswordError*(self: AccessInterface, errorDescription: string
method emitStoringPasswordSuccess*(self: AccessInterface) {.base.} = method emitStoringPasswordSuccess*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method emitMailserverNotWorking*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method activeSectionSet*(self: AccessInterface, sectionId: string) {.base.} = method activeSectionSet*(self: AccessInterface, sectionId: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -444,6 +444,9 @@ method emitStoringPasswordError*[T](self: Module[T], errorDescription: string) =
method emitStoringPasswordSuccess*[T](self: Module[T]) = method emitStoringPasswordSuccess*[T](self: Module[T]) =
self.view.emitStoringPasswordSuccess() self.view.emitStoringPasswordSuccess()
method emitMailserverNotWorking*[T](self: Module[T]) =
self.view.emitMailserverNotWorking()
method getActiveSectionId*[T](self: Module[T]): string = method getActiveSectionId*[T](self: Module[T]): string =
return self.controller.getActiveSectionId() return self.controller.getActiveSectionId()

View File

@ -94,6 +94,11 @@ QtObject:
proc emitStoringPasswordSuccess*(self: View) = proc emitStoringPasswordSuccess*(self: View) =
self.storingPasswordSuccess() self.storingPasswordSuccess()
proc mailserverNotWorking*(self:View) {.signal.}
proc emitMailservernotWorking*(self: View) =
self.mailserverNotWorking()
proc activeSection*(self: View): ActiveSection = proc activeSection*(self: View): ActiveSection =
return self.activeSection return self.activeSection

View File

@ -28,6 +28,7 @@ type
# Signals which may be emitted by this service: # Signals which may be emitted by this service:
const SIGNAL_ACTIVE_MAILSERVER_CHANGED* = "activeMailserverChanged" const SIGNAL_ACTIVE_MAILSERVER_CHANGED* = "activeMailserverChanged"
const SIGNAL_MAILSERVER_AVAILABLE* = "mailserverAvailable" const SIGNAL_MAILSERVER_AVAILABLE* = "mailserverAvailable"
const SIGNAL_MAILSERVER_NOT_WORKING* = "mailserverNotWorking"
const requestMoreMessagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = const requestMoreMessagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[RequestMoreMessagesTaskArg](argEncoded) let arg = decode[RequestMoreMessagesTaskArg](argEncoded)
@ -109,6 +110,10 @@ QtObject:
let data = MailserverAvailableArgs() let data = MailserverAvailableArgs()
self.events.emit(SIGNAL_MAILSERVER_AVAILABLE, data) self.events.emit(SIGNAL_MAILSERVER_AVAILABLE, data)
self.events.on(SignalType.MailserverNotWorking.event) do(e: Args):
info "mailserver not working"
self.events.emit(SIGNAL_MAILSERVER_NOT_WORKING, Args())
self.events.on(SignalType.HistoryRequestStarted.event) do(e: Args): self.events.on(SignalType.HistoryRequestStarted.event) do(e: Args):
let h = HistoryRequestStartedSignal(e) let h = HistoryRequestStartedSignal(e)
info "history request started", requestId=h.requestId, numBatches=h.numBatches info "history request started", requestId=h.requestId, numBatches=h.numBatches

View File

@ -32,6 +32,7 @@ proc decode*(jsonSignal: JsonNode): Signal =
of SignalType.KeycardConnected: KeycardConnectedSignal.fromEvent(jsonSignal) of SignalType.KeycardConnected: KeycardConnectedSignal.fromEvent(jsonSignal)
of SignalType.MailserverAvailable: MailserverAvailableSignal.fromEvent(jsonSignal) of SignalType.MailserverAvailable: MailserverAvailableSignal.fromEvent(jsonSignal)
of SignalType.MailserverChanged: MailserverChangedSignal.fromEvent(jsonSignal) of SignalType.MailserverChanged: MailserverChangedSignal.fromEvent(jsonSignal)
of SignalType.MailserverNotWorking: MailserverNotWorkingSignal.fromEvent(jsonSignal)
of SignalType.HistoryArchivesProtocolEnabled: historyArchivesProtocolEnabledFromEvent(jsonSignal) of SignalType.HistoryArchivesProtocolEnabled: historyArchivesProtocolEnabledFromEvent(jsonSignal)
of SignalType.HistoryArchivesProtocolDisabled: historyArchivesProtocolDisabledFromEvent(jsonSignal) of SignalType.HistoryArchivesProtocolDisabled: historyArchivesProtocolDisabledFromEvent(jsonSignal)
of SignalType.CreatingHistoryArchives: creatingHistoryArchivesFromEvent(jsonSignal) of SignalType.CreatingHistoryArchives: creatingHistoryArchivesFromEvent(jsonSignal)

View File

@ -626,8 +626,56 @@ Item {
} }
} }
} }
Connections {
target: rootStore.mainModuleInst
onMailserverNotWorking: {
Global.openPopup(mailserverNotWorkingPopupComponent);
}
}
} }
Component {
id: mailserverNotWorkingPopupComponent
StatusModal {
id: msNotWorkingPopup
anchors.centerIn: parent
header.title: qsTr("Can not connect to mailserver")
onClosed: {
destroy()
}
contentItem: Item {
width: msNotWorkingPopup.width
implicitHeight: 100
StatusBaseText {
text: qsTr("The mailserver you're connecting to is unavailable.")
color: Theme.palette.directColor1
anchors.centerIn: parent
}
}
rightButtons: [
StatusButton {
text: qsTr("Pick another")
onClicked: {
Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.messaging)
msNotWorkingPopup.close()
}
},
StatusButton {
text: qsTr("Retry")
onClicked: {
// Retrying already happens automatically, so doing nothing
// here is the same as retrying...
msNotWorkingPopup.close()
}
}
]
}
}
Component { Component {
id: chooseBrowserPopupComponent id: chooseBrowserPopupComponent
ChooseBrowserPopup { ChooseBrowserPopup {