fix(HistoryNodes): Fix mailserver management UI controllers
Fixes #14982
This commit is contained in:
parent
c4928cfe40
commit
3345a9cc48
|
@ -33,6 +33,7 @@ type MailserverAvailableSignal* = ref object of Signal
|
||||||
|
|
||||||
type MailserverChangedSignal* = ref object of Signal
|
type MailserverChangedSignal* = ref object of Signal
|
||||||
address*: string
|
address*: string
|
||||||
|
id*: string
|
||||||
|
|
||||||
type MailserverNotWorkingSignal* = ref object of Signal
|
type MailserverNotWorkingSignal* = ref object of Signal
|
||||||
|
|
||||||
|
@ -84,6 +85,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()
|
||||||
|
result.id = jsonSignal["event"]{"id"}.getStr()
|
||||||
|
|
||||||
proc fromEvent*(T: type MailserverNotWorkingSignal, jsonSignal: JsonNode): MailserverNotWorkingSignal =
|
proc fromEvent*(T: type MailserverNotWorkingSignal, jsonSignal: JsonNode): MailserverNotWorkingSignal =
|
||||||
result = MailserverNotWorkingSignal()
|
result = MailserverNotWorkingSignal()
|
||||||
|
|
|
@ -34,19 +34,24 @@ proc delete*(self: Controller) =
|
||||||
|
|
||||||
proc init*(self: Controller) =
|
proc init*(self: Controller) =
|
||||||
self.events.on(SIGNAL_ACTIVE_MAILSERVER_CHANGED) do(e: Args):
|
self.events.on(SIGNAL_ACTIVE_MAILSERVER_CHANGED) do(e: Args):
|
||||||
var args = ActiveMailserverChangedArgs(e)
|
self.delegate.onActiveMailserverChanged()
|
||||||
self.delegate.onActiveMailserverChanged(args.nodeAddress)
|
|
||||||
|
self.events.on(SIGNAL_PINNED_MAILSERVER_CHANGED) do(e: Args):
|
||||||
|
self.delegate.onPinnedMailserverChanged()
|
||||||
|
|
||||||
proc getAllMailservers*(self: Controller): seq[tuple[name: string, nodeAddress: string]] =
|
proc getAllMailservers*(self: Controller): seq[tuple[name: string, nodeAddress: string]] =
|
||||||
return self.mailserversService.getAllMailservers()
|
return self.mailserversService.getAllMailservers()
|
||||||
|
|
||||||
proc getPinnedMailserver*(self: Controller): string =
|
proc getPinnedMailserverId*(self: Controller): string =
|
||||||
let fleet = self.nodeConfigurationService.getFleet()
|
let fleet = self.nodeConfigurationService.getFleet()
|
||||||
self.settingsService.getPinnedMailserver(fleet)
|
self.settingsService.getPinnedMailserverId(fleet)
|
||||||
|
|
||||||
proc pinMailserver*(self: Controller, mailserverID: string) =
|
proc setPinnedMailserverId*(self: Controller, mailserverID: string) =
|
||||||
let fleet = self.nodeConfigurationService.getFleet()
|
let fleet = self.nodeConfigurationService.getFleet()
|
||||||
discard self.settingsService.pinMailserver(mailserverID, fleet)
|
discard self.settingsService.setPinnedMailserverId(mailserverID, fleet)
|
||||||
|
|
||||||
|
proc getActiveMailserverId*(self: Controller): string =
|
||||||
|
return self.mailserversService.getActiveMailserverId()
|
||||||
|
|
||||||
proc saveNewMailserver*(self: Controller, name: string, nodeAddress: string) =
|
proc saveNewMailserver*(self: Controller, name: string, nodeAddress: string) =
|
||||||
discard self.mailserversService.saveMailserver(name, nodeAddress)
|
discard self.mailserversService.saveMailserver(name, nodeAddress)
|
||||||
|
@ -58,4 +63,4 @@ proc getUseMailservers*(self: Controller): bool =
|
||||||
return self.settingsService.getUseMailservers()
|
return self.settingsService.getUseMailservers()
|
||||||
|
|
||||||
proc setUseMailservers*(self: Controller, value: bool): bool =
|
proc setUseMailservers*(self: Controller, value: bool): bool =
|
||||||
return self.settingsService.saveUseMailservers(value)
|
return self.settingsService.toggleUseMailservers(value)
|
|
@ -15,7 +15,10 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||||
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
|
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method onActiveMailserverChanged*(self: AccessInterface, nodeAddress: string) {.base.} =
|
method onActiveMailserverChanged*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method onPinnedMailserverChanged*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||||
|
@ -24,10 +27,13 @@ method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||||
method isAutomaticSelection*(self: AccessInterface): bool {.base.} =
|
method isAutomaticSelection*(self: AccessInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method getMailserverNameForNodeAddress*(self: AccessInterface, nodeAddress: string): string {.base.} =
|
method getActiveMailserverId*(self: AccessInterface): string {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method setActiveMailserver*(self: AccessInterface, mailserverID: string) {.base.} =
|
method getPinnedMailserverId*(self: AccessInterface): string {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method setPinnedMailserverId*(self: AccessInterface, mailserverID: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method saveNewMailserver*(self: AccessInterface, name: string, nodeAddress: string) {.base.} =
|
method saveNewMailserver*(self: AccessInterface, name: string, nodeAddress: string) {.base.} =
|
||||||
|
|
|
@ -63,19 +63,23 @@ method getModuleAsVariant*(self: Module): QVariant =
|
||||||
return self.viewVariant
|
return self.viewVariant
|
||||||
|
|
||||||
method isAutomaticSelection*(self: Module): bool =
|
method isAutomaticSelection*(self: Module): bool =
|
||||||
return self.controller.getPinnedMailserver().len == 0
|
return self.controller.getPinnedMailserverId().len == 0
|
||||||
|
|
||||||
method onActiveMailserverChanged*(self: Module, nodeAddress: string) =
|
method onActiveMailserverChanged*(self: Module) =
|
||||||
self.view.onActiveMailserverSet(nodeAddress)
|
self.view.onActiveMailserverSet()
|
||||||
|
|
||||||
method getMailserverNameForNodeAddress*(self: Module, nodeAddress: string): string =
|
method onPinnedMailserverChanged*(self: Module) =
|
||||||
let name = self.view.model().getNameForNodeAddress(nodeAddress)
|
self.view.onPinnedMailserverSet()
|
||||||
if(name.len > 0):
|
|
||||||
return name
|
|
||||||
return "---"
|
|
||||||
|
|
||||||
method setActiveMailserver*(self: Module, mailserverID: string) =
|
method setPinnedMailserverId*(self: Module, mailserverID: string) =
|
||||||
self.controller.pinMailserver(mailserverID)
|
self.controller.setPinnedMailserverId(mailserverID)
|
||||||
|
|
||||||
|
method getPinnedMailserverId*(self: Module): string =
|
||||||
|
return self.controller.getPinnedMailserverId()
|
||||||
|
|
||||||
|
method getActiveMailserverId*(self: Module): string =
|
||||||
|
let res = self.controller.getActiveMailserverId()
|
||||||
|
return res
|
||||||
|
|
||||||
method saveNewMailserver*(self: Module, name: string, nodeAddress: string) =
|
method saveNewMailserver*(self: Module, name: string, nodeAddress: string) =
|
||||||
self.controller.saveNewMailserver(name, nodeAddress)
|
self.controller.saveNewMailserver(name, nodeAddress)
|
||||||
|
@ -90,5 +94,5 @@ method getUseMailservers*(self: Module): bool =
|
||||||
return self.controller.getUseMailservers()
|
return self.controller.getUseMailservers()
|
||||||
|
|
||||||
method setUseMailservers*(self: Module, value: bool) =
|
method setUseMailservers*(self: Module, value: bool) =
|
||||||
if (self.controller.setUseMailservers(value)):
|
if self.controller.setUseMailservers(value):
|
||||||
self.view.useMailserversChanged()
|
self.view.useMailserversChanged()
|
||||||
|
|
|
@ -5,7 +5,6 @@ QtObject:
|
||||||
type
|
type
|
||||||
View* = ref object of QObject
|
View* = ref object of QObject
|
||||||
delegate: io_interface.AccessInterface
|
delegate: io_interface.AccessInterface
|
||||||
activeMailserver: string
|
|
||||||
model: Model
|
model: Model
|
||||||
modelVariant: QVariant
|
modelVariant: QVariant
|
||||||
|
|
||||||
|
@ -18,7 +17,6 @@ QtObject:
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.QObject.setup
|
result.QObject.setup
|
||||||
result.delegate = delegate
|
result.delegate = delegate
|
||||||
result.activeMailserver = ""
|
|
||||||
result.model = newModel()
|
result.model = newModel()
|
||||||
result.modelVariant = newQVariant(result.model)
|
result.modelVariant = newQVariant(result.model)
|
||||||
|
|
||||||
|
@ -31,33 +29,49 @@ QtObject:
|
||||||
proc modelChanged*(self: View) {.signal.}
|
proc modelChanged*(self: View) {.signal.}
|
||||||
proc getModel(self: View): QVariant {.slot.} =
|
proc getModel(self: View): QVariant {.slot.} =
|
||||||
return self.modelVariant
|
return self.modelVariant
|
||||||
|
|
||||||
QtProperty[QVariant] model:
|
QtProperty[QVariant] model:
|
||||||
read = getModel
|
read = getModel
|
||||||
notify = modelChanged
|
notify = modelChanged
|
||||||
|
|
||||||
proc isAutomaticSelection(self: View): bool {.slot.} =
|
proc isAutomaticSelection(self: View): bool {.slot.} =
|
||||||
return self.delegate.isAutomaticSelection()
|
return self.delegate.isAutomaticSelection()
|
||||||
|
|
||||||
QtProperty[bool] automaticSelection:
|
QtProperty[bool] automaticSelection:
|
||||||
read = isAutomaticSelection
|
read = isAutomaticSelection
|
||||||
|
notify = pinnedMailserverIdChanged
|
||||||
|
|
||||||
proc activeMailserverChanged*(self: View) {.signal.}
|
proc activeMailserverIdChanged*(self: View) {.signal.}
|
||||||
proc getActiveMailserver(self: View): string {.slot.} =
|
|
||||||
return self.activeMailserver
|
|
||||||
QtProperty[string] activeMailserver:
|
|
||||||
read = getActiveMailserver
|
|
||||||
notify = activeMailserverChanged
|
|
||||||
|
|
||||||
proc setActiveMailserver(self: View, mailserverID: string) {.slot.} =
|
proc getActiveMailserverId(self: View): string {.slot.} =
|
||||||
self.delegate.setActiveMailserver(mailserverID)
|
let res = self.delegate.getActiveMailserverId()
|
||||||
|
return res
|
||||||
|
|
||||||
proc onActiveMailserverSet*(self: View, nodeAddress: string) =
|
QtProperty[string] activeMailserverId:
|
||||||
if(self.activeMailserver == nodeAddress):
|
read = getActiveMailserverId
|
||||||
|
notify = activeMailserverIdChanged
|
||||||
|
|
||||||
|
proc onActiveMailserverSet*(self: View) =
|
||||||
|
self.activeMailserverIdChanged()
|
||||||
|
|
||||||
|
proc pinnedMailserverIdChanged*(self: View) {.signal.}
|
||||||
|
|
||||||
|
proc getPinnedMailserverId(self: View): string {.slot.} =
|
||||||
|
let res = self.delegate.getPinnedMailserverId()
|
||||||
|
return res
|
||||||
|
|
||||||
|
QtProperty[string] pinnedMailserverId:
|
||||||
|
read = getPinnedMailserverId
|
||||||
|
write = setPinnedMailserverId
|
||||||
|
notify = pinnedMailserverIdChanged
|
||||||
|
|
||||||
|
proc setPinnedMailserverId(self: View, mailserverID: string) {.slot.} =
|
||||||
|
if mailserverID == self.getPinnedMailserverId():
|
||||||
return
|
return
|
||||||
self.activeMailserver = nodeAddress
|
self.delegate.setPinnedMailserverId(mailserverID)
|
||||||
self.activeMailserverChanged()
|
|
||||||
|
|
||||||
proc getMailserverNameForNodeAddress*(self: View, nodeAddress: string): string {.slot.} =
|
proc onPinnedMailserverSet*(self: View) =
|
||||||
self.delegate.getMailserverNameForNodeAddress(nodeAddress)
|
self.pinnedMailserverIdChanged()
|
||||||
|
|
||||||
proc saveNewMailserver(self: View, name: string, address: string) {.slot.} =
|
proc saveNewMailserver(self: View, name: string, address: string) {.slot.} =
|
||||||
self.delegate.saveNewMailserver(name, address)
|
self.delegate.saveNewMailserver(name, address)
|
||||||
|
@ -71,6 +85,8 @@ QtObject:
|
||||||
return self.delegate.getUseMailservers()
|
return self.delegate.getUseMailservers()
|
||||||
|
|
||||||
proc setUseMailservers*(self: View, value: bool) {.slot.} =
|
proc setUseMailservers*(self: View, value: bool) {.slot.} =
|
||||||
|
if value == self.delegate.getUseMailservers():
|
||||||
|
return
|
||||||
self.delegate.setUseMailservers(value)
|
self.delegate.setUseMailservers(value)
|
||||||
|
|
||||||
QtProperty[bool] useMailservers:
|
QtProperty[bool] useMailservers:
|
||||||
|
|
|
@ -23,6 +23,7 @@ logScope:
|
||||||
type
|
type
|
||||||
ActiveMailserverChangedArgs* = ref object of Args
|
ActiveMailserverChangedArgs* = ref object of Args
|
||||||
nodeAddress*: string
|
nodeAddress*: string
|
||||||
|
nodeId*: string
|
||||||
|
|
||||||
MailserverAvailableArgs* = ref object of Args
|
MailserverAvailableArgs* = ref object of Args
|
||||||
|
|
||||||
|
@ -80,6 +81,7 @@ QtObject:
|
||||||
settingsService: settings_service.Service
|
settingsService: settings_service.Service
|
||||||
nodeConfigurationService: node_configuration_service.Service
|
nodeConfigurationService: node_configuration_service.Service
|
||||||
fleetConfiguration: FleetConfiguration
|
fleetConfiguration: FleetConfiguration
|
||||||
|
activeMailserverData: ActiveMailserverChangedArgs
|
||||||
|
|
||||||
# Forward declaration:
|
# Forward declaration:
|
||||||
proc doConnect(self: Service)
|
proc doConnect(self: Service)
|
||||||
|
@ -101,6 +103,7 @@ QtObject:
|
||||||
result.settingsService = settingsService
|
result.settingsService = settingsService
|
||||||
result.nodeConfigurationService = nodeConfigurationService
|
result.nodeConfigurationService = nodeConfigurationService
|
||||||
result.fleetConfiguration = fleetConfiguration
|
result.fleetConfiguration = fleetConfiguration
|
||||||
|
result.activeMailserverData = ActiveMailserverChangedArgs(nodeAddress: "", nodeId: "")
|
||||||
|
|
||||||
proc init*(self: Service) =
|
proc init*(self: Service) =
|
||||||
self.doConnect()
|
self.doConnect()
|
||||||
|
@ -118,10 +121,10 @@ QtObject:
|
||||||
let mailserverName = "Test Mailserver"
|
let mailserverName = "Test Mailserver"
|
||||||
self.mailservers.add((name: mailserverName, nodeAddress: TEST_PEER_ENR))
|
self.mailservers.add((name: mailserverName, nodeAddress: TEST_PEER_ENR))
|
||||||
let mailserverID = self.saveMailserver(mailserverName, TEST_PEER_ENR)
|
let mailserverID = self.saveMailserver(mailserverName, TEST_PEER_ENR)
|
||||||
discard self.settingsService.pinMailserver(mailserverId, fleet)
|
discard self.settingsService.setPinnedMailserverId(mailserverId, fleet)
|
||||||
|
|
||||||
if MAILSERVER_ID != "":
|
if MAILSERVER_ID != "":
|
||||||
discard self.settingsService.pinMailserver(MAILSERVER_ID, fleet)
|
discard self.settingsService.setPinnedMailserverId(MAILSERVER_ID, fleet)
|
||||||
|
|
||||||
proc requestMoreMessages*(self: Service, chatId: string) =
|
proc requestMoreMessages*(self: Service, chatId: string) =
|
||||||
let arg = RequestMoreMessagesTaskArg(
|
let arg = RequestMoreMessagesTaskArg(
|
||||||
|
@ -144,13 +147,14 @@ QtObject:
|
||||||
self.events.on(SignalType.MailserverChanged.event) do(e: Args):
|
self.events.on(SignalType.MailserverChanged.event) do(e: Args):
|
||||||
let receivedData = MailserverChangedSignal(e)
|
let receivedData = MailserverChangedSignal(e)
|
||||||
let address = receivedData.address
|
let address = receivedData.address
|
||||||
|
let id = receivedData.id
|
||||||
|
|
||||||
if address == "":
|
if address == "":
|
||||||
info "removing active mailserver"
|
info "removing active mailserver"
|
||||||
else:
|
else:
|
||||||
info "active mailserver changed", node=address
|
info "active mailserver changed", node=address, id = id
|
||||||
let data = ActiveMailserverChangedArgs(nodeAddress: address)
|
self.activeMailserverData = ActiveMailserverChangedArgs(nodeAddress: address, nodeId: id)
|
||||||
self.events.emit(SIGNAL_ACTIVE_MAILSERVER_CHANGED, data)
|
self.events.emit(SIGNAL_ACTIVE_MAILSERVER_CHANGED, self.activeMailserverData)
|
||||||
|
|
||||||
self.events.on(SignalType.MailserverAvailable.event) do(e: Args):
|
self.events.on(SignalType.MailserverAvailable.event) do(e: Args):
|
||||||
info "mailserver available"
|
info "mailserver available"
|
||||||
|
@ -179,7 +183,6 @@ QtObject:
|
||||||
let h = HistoryRequestSuccessSignal(e)
|
let h = HistoryRequestSuccessSignal(e)
|
||||||
info "history request success", requestId=h.requestId, peerId=h.peerId
|
info "history request success", requestId=h.requestId, peerId=h.peerId
|
||||||
|
|
||||||
|
|
||||||
proc initMailservers(self: Service) =
|
proc initMailservers(self: Service) =
|
||||||
let fleet = self.nodeConfigurationService.getFleet()
|
let fleet = self.nodeConfigurationService.getFleet()
|
||||||
let mailservers = self.fleetConfiguration.getMailservers(fleet)
|
let mailservers = self.fleetConfiguration.getMailservers(fleet)
|
||||||
|
@ -188,6 +191,9 @@ QtObject:
|
||||||
info "initMailservers", topics="mailserver-interaction", name, nodeAddress
|
info "initMailservers", topics="mailserver-interaction", name, nodeAddress
|
||||||
self.mailservers.add((name: name, nodeAddress: nodeAddress))
|
self.mailservers.add((name: name, nodeAddress: nodeAddress))
|
||||||
|
|
||||||
|
proc getActiveMailserverId*(self: Service): string =
|
||||||
|
return self.activeMailserverData.nodeId
|
||||||
|
|
||||||
proc fetchMailservers(self: Service) =
|
proc fetchMailservers(self: Service) =
|
||||||
try:
|
try:
|
||||||
let response = status_mailservers.getMailservers()
|
let response = status_mailservers.getMailservers()
|
||||||
|
@ -235,7 +241,3 @@ QtObject:
|
||||||
# slot: "onActiveMailserverResult"
|
# slot: "onActiveMailserverResult"
|
||||||
# )
|
# )
|
||||||
#mailserverWorker.start(task)
|
#mailserverWorker.start(task)
|
||||||
|
|
||||||
proc onActiveMailserverResult*(self: Service, response: string) {.slot.} =
|
|
||||||
let fleet = self.nodeConfigurationService.getFleet()
|
|
||||||
discard self.settingsService.pinMailserver(response, fleet)
|
|
||||||
|
|
|
@ -255,6 +255,6 @@ proc pinnedMailserverToJsonNode*(mailserver: PinnedMailserver): JsonNode =
|
||||||
"waku.test": mailserver.wakuTest,
|
"waku.test": mailserver.wakuTest,
|
||||||
"status.test": mailserver.statusTest,
|
"status.test": mailserver.statusTest,
|
||||||
"status.prod": mailserver.statusProd,
|
"status.prod": mailserver.statusProd,
|
||||||
"shard.test": mailserver.shardsTest,
|
"shards.test": mailserver.shardsTest,
|
||||||
"sharding.staging": mailserver.shardsStaging,
|
"sharding.staging": mailserver.shardsStaging,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import NimQml, chronicles, json, strutils, sequtils, tables
|
import NimQml, chronicles, json, strutils, sequtils, tables
|
||||||
|
|
||||||
import app_service/common/types as common_types
|
|
||||||
import app/core/eventemitter
|
import app/core/eventemitter
|
||||||
import app/core/fleets/fleet_configuration
|
import app/core/fleets/fleet_configuration
|
||||||
import app/core/signals/types
|
import app/core/signals/types
|
||||||
|
import app_service/common/types as common_types
|
||||||
|
import backend/mailservers as status_mailservers
|
||||||
import backend/settings as status_settings
|
import backend/settings as status_settings
|
||||||
import backend/status_update as status_update
|
import backend/status_update as status_update
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ const SIGNAL_MNEMONIC_REMOVED* = "mnemonicRemoved"
|
||||||
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
|
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
|
||||||
const SIGNAL_PROFILE_MIGRATION_NEEDED_UPDATED* = "profileMigrationNeededUpdated"
|
const SIGNAL_PROFILE_MIGRATION_NEEDED_UPDATED* = "profileMigrationNeededUpdated"
|
||||||
const SIGNAL_URL_UNFURLING_MODE_UPDATED* = "urlUnfurlingModeUpdated"
|
const SIGNAL_URL_UNFURLING_MODE_UPDATED* = "urlUnfurlingModeUpdated"
|
||||||
|
const SIGNAL_PINNED_MAILSERVER_CHANGED* = "pinnedMailserverChanged"
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "settings-service"
|
topics = "settings-service"
|
||||||
|
@ -328,11 +330,18 @@ QtObject:
|
||||||
proc getAppearance*(self: Service): int =
|
proc getAppearance*(self: Service): int =
|
||||||
self.settings.appearance
|
self.settings.appearance
|
||||||
|
|
||||||
proc saveUseMailservers*(self: Service, value: bool): bool =
|
proc toggleUseMailservers*(self: Service, value: bool): bool =
|
||||||
if(self.saveSetting(KEY_USE_MAILSERVERS, value)):
|
try:
|
||||||
self.settings.useMailservers = value
|
let response = status_mailservers.toggleUseMailservers(value)
|
||||||
return true
|
if not response.error.isNil:
|
||||||
|
error "error saving use mailservers: ", errDescription = response.error.message
|
||||||
return false
|
return false
|
||||||
|
self.settings.useMailservers = value
|
||||||
|
except Exception as e:
|
||||||
|
let errDesription = e.msg
|
||||||
|
error "saving use mailservers error: ", errDesription
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
|
||||||
proc getUseMailservers*(self: Service): bool =
|
proc getUseMailservers*(self: Service): bool =
|
||||||
self.settings.useMailservers
|
self.settings.useMailservers
|
||||||
|
@ -390,36 +399,52 @@ QtObject:
|
||||||
proc getCurrentUserStatus*(self: Service): CurrentUserStatus =
|
proc getCurrentUserStatus*(self: Service): CurrentUserStatus =
|
||||||
self.settings.currentUserStatus
|
self.settings.currentUserStatus
|
||||||
|
|
||||||
proc getPinnedMailserver*(self: Service, fleet: Fleet): string =
|
proc getPinnedMailserverId*(self: Service, fleet: Fleet): string =
|
||||||
if (fleet == Fleet.WakuSandbox):
|
case fleet:
|
||||||
|
of Fleet.WakuSandbox:
|
||||||
return self.settings.pinnedMailserver.wakuSandbox
|
return self.settings.pinnedMailserver.wakuSandbox
|
||||||
elif (fleet == Fleet.WakuTest):
|
of Fleet.WakuTest:
|
||||||
return self.settings.pinnedMailserver.wakuTest
|
return self.settings.pinnedMailserver.wakuTest
|
||||||
elif (fleet == Fleet.ShardsTest):
|
of Fleet.ShardsTest:
|
||||||
return self.settings.pinnedMailserver.shardsTest
|
return self.settings.pinnedMailserver.shardsTest
|
||||||
elif (fleet == Fleet.ShardsStaging):
|
of Fleet.ShardsStaging:
|
||||||
return self.settings.pinnedMailserver.shardsStaging
|
return self.settings.pinnedMailserver.shardsStaging
|
||||||
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
proc pinMailserver*(self: Service, mailserverID: string, fleet: Fleet): bool =
|
proc setPinnedMailserverId*(self: Service, mailserverID: string, fleet: Fleet): bool =
|
||||||
if fleet == Fleet.Undefined:
|
if fleet == Fleet.Undefined:
|
||||||
return false
|
return false
|
||||||
var newMailserverJsonObj = self.settings.pinnedMailserver.pinnedMailserverToJsonNode()
|
var newMailserverJsonObj = self.settings.pinnedMailserver.pinnedMailserverToJsonNode()
|
||||||
newMailserverJsonObj[$fleet] = %* mailserverID
|
newMailserverJsonObj[$fleet] = %* mailserverID
|
||||||
if(self.saveSetting(KEY_PINNED_MAILSERVERS, newMailserverJsonObj)):
|
|
||||||
if (fleet == Fleet.WakuSandbox):
|
try:
|
||||||
self.settings.pinnedMailserver.wakuSandbox = mailserverID
|
let response = status_mailservers.setPinnedMailservers(newMailserverJsonObj)
|
||||||
elif (fleet == Fleet.WakuTest):
|
if not response.error.isNil:
|
||||||
self.settings.pinnedMailserver.wakuTest = mailserverID
|
error "error saving pinned mailserver: ", errDescription = response.error.message
|
||||||
elif (fleet == Fleet.ShardsTest):
|
|
||||||
self.settings.pinnedMailserver.shardsTest = mailserverID
|
|
||||||
elif (fleet == Fleet.ShardsStaging):
|
|
||||||
self.settings.pinnedMailserver.shardsStaging = mailserverID
|
|
||||||
return true
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
case fleet:
|
||||||
|
of Fleet.WakuSandbox:
|
||||||
|
self.settings.pinnedMailserver.wakuSandbox = mailserverID
|
||||||
|
of Fleet.WakuTest:
|
||||||
|
self.settings.pinnedMailserver.wakuTest = mailserverID
|
||||||
|
of Fleet.ShardsTest:
|
||||||
|
self.settings.pinnedMailserver.shardsTest = mailserverID
|
||||||
|
of Fleet.ShardsStaging:
|
||||||
|
self.settings.pinnedMailserver.shardsStaging = mailserverID
|
||||||
|
else:
|
||||||
|
return false
|
||||||
|
except Exception as e:
|
||||||
|
let errDesription = e.msg
|
||||||
|
error "saving pinned mailserver error: ", errDesription
|
||||||
|
return false
|
||||||
|
|
||||||
|
self.events.emit(SIGNAL_PINNED_MAILSERVER_CHANGED, Args())
|
||||||
|
return true
|
||||||
|
|
||||||
proc unpinMailserver*(self: Service, fleet: Fleet): bool =
|
proc unpinMailserver*(self: Service, fleet: Fleet): bool =
|
||||||
return self.pinMailserver("", fleet)
|
return self.setPinnedMailserverId("", fleet)
|
||||||
|
|
||||||
proc saveNodeConfiguration*(self: Service, value: JsonNode): bool =
|
proc saveNodeConfiguration*(self: Service, value: JsonNode): bool =
|
||||||
if(self.saveSetting(KEY_NODE_CONFIG, value)):
|
if(self.saveSetting(KEY_NODE_CONFIG, value)):
|
||||||
|
|
|
@ -20,6 +20,12 @@ proc saveMailserver*(id: string, name: string, enode: string, fleet: string):
|
||||||
proc getMailservers*(): RpcResponse[JsonNode] =
|
proc getMailservers*(): RpcResponse[JsonNode] =
|
||||||
result = core.callPrivateRPC("mailservers_getMailservers")
|
result = core.callPrivateRPC("mailservers_getMailservers")
|
||||||
|
|
||||||
|
proc setPinnedMailservers*(mailservers: JsonNode): RpcResponse[JsonNode] =
|
||||||
|
result = core.callPrivateRPC("setPinnedMailservers".prefix, %*[ mailservers ])
|
||||||
|
|
||||||
|
proc toggleUseMailservers*(value: bool): RpcResponse[JsonNode] =
|
||||||
|
result = core.callPrivateRPC("toggleUseMailservers".prefix, %*[ value ])
|
||||||
|
|
||||||
proc syncChatFromSyncedFrom*(chatId: string): RpcResponse[JsonNode] =
|
proc syncChatFromSyncedFrom*(chatId: string): RpcResponse[JsonNode] =
|
||||||
let payload = %*[chatId]
|
let payload = %*[chatId]
|
||||||
result = core.callPrivateRPC("syncChatFromSyncedFrom".prefix, payload)
|
result = core.callPrivateRPC("syncChatFromSyncedFrom".prefix, payload)
|
||||||
|
|
|
@ -100,10 +100,10 @@ StatusModal {
|
||||||
StatusRadioButton {
|
StatusRadioButton {
|
||||||
id: nodeRadioBtn
|
id: nodeRadioBtn
|
||||||
ButtonGroup.group: nodesButtonGroup
|
ButtonGroup.group: nodesButtonGroup
|
||||||
checked: model.nodeAddress === root.messagingStore.activeMailserver
|
checked: model.name === root.messagingStore.pinnedMailserverId
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
root.messagingStore.setActiveMailserver(model.name)
|
root.messagingStore.setPinnedMailserverId(model.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,12 @@ QtObject {
|
||||||
|
|
||||||
// Module Properties
|
// Module Properties
|
||||||
property bool automaticMailserverSelection: syncModule.automaticSelection
|
property bool automaticMailserverSelection: syncModule.automaticSelection
|
||||||
property string activeMailserver: syncModule.activeMailserver
|
property string activeMailserverId: syncModule.activeMailserverId
|
||||||
|
property string pinnedMailserverId: syncModule.pinnedMailserverId
|
||||||
|
|
||||||
function getMailserverNameForNodeAddress(nodeAddress) {
|
|
||||||
return root.syncModule.getMailserverNameForNodeAddress(nodeAddress)
|
|
||||||
}
|
|
||||||
|
|
||||||
function setActiveMailserver(mailserverID) {
|
function setPinnedMailserverId(mailserverID) {
|
||||||
root.syncModule.setActiveMailserver(mailserverID)
|
root.syncModule.setPinnedMailserverId(mailserverID)
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveNewMailserver(name, nodeAddress) {
|
function saveNewMailserver(name, nodeAddress) {
|
||||||
|
|
|
@ -314,7 +314,7 @@ SettingsContentBase {
|
||||||
anchors.leftMargin: Style.current.padding
|
anchors.leftMargin: Style.current.padding
|
||||||
anchors.rightMargin: Style.current.padding
|
anchors.rightMargin: Style.current.padding
|
||||||
title: qsTr("History nodes")
|
title: qsTr("History nodes")
|
||||||
label: root.messagingStore.getMailserverNameForNodeAddress(root.messagingStore.activeMailserver)
|
label: root.messagingStore.activeMailserverId || "---"
|
||||||
components: [
|
components: [
|
||||||
StatusIcon {
|
StatusIcon {
|
||||||
icon: "next"
|
icon: "next"
|
||||||
|
|
Loading…
Reference in New Issue