fix(@desktop/sync): settings/display_name sync&backup handling

Part of #10389 issue.
This commit is contained in:
Sale Djenic 2023-05-30 13:54:01 +02:00 committed by saledjenic
parent 1e406269df
commit 5bfd4546c2
2 changed files with 8 additions and 4 deletions

View File

@ -27,7 +27,9 @@ proc newService*(events: EventEmitter, settingsService: settings_service.Service
result.settingsService = settingsService
proc init*(self: Service) =
discard
self.events.on(SIGNAL_DISPLAY_NAME_UPDATED) do(e:Args):
let args = SettingsTextValueArgs(e)
singletonInstance.userProfile.setDisplayName(args.value)
proc storeIdentityImage*(self: Service, address: string, image: string, aX: int, aY: int, bX: int, bY: int): seq[Image] =
try:
@ -74,8 +76,5 @@ proc setDisplayName*(self: Service, displayName: string) =
if(not self.settingsService.saveDisplayName(displayName)):
error "could save display name to the settings"
return
singletonInstance.userProfile.setDisplayName(displayName)
except Exception as e:
error "error: ", procName="setDisplayName", errName = e.name, errDesription = e.msg

View File

@ -22,6 +22,7 @@ const DEFAULT_FLEET* = $Fleet.StatusProd
# Signals:
const SIGNAL_CURRENCY_UPDATED* = "currencyUpdated"
const SIGNAL_DISPLAY_NAME_UPDATED* = "displayNameUpdated"
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
logScope:
@ -90,6 +91,9 @@ QtObject:
if settingsField.name == KEY_CURRENCY:
self.settings.currency = settingsField.value
self.events.emit(SIGNAL_CURRENCY_UPDATED, SettingsTextValueArgs(value: settingsField.value))
if settingsField.name == KEY_DISPLAY_NAME:
self.settings.displayName = settingsField.value
self.events.emit(SIGNAL_DISPLAY_NAME_UPDATED, SettingsTextValueArgs(value: settingsField.value))
self.initialized = true
@ -185,6 +189,7 @@ QtObject:
proc saveDisplayName*(self: Service, value: string): bool =
if(self.saveSetting(KEY_DISPLAY_NAME, value)):
self.settings.displayName = value
self.events.emit(SIGNAL_DISPLAY_NAME_UPDATED, SettingsTextValueArgs(value: self.settings.displayName))
return true
return false