fix(Privacy): handle sync setting for `profile-pictures-visibility`

Part of #5201
This commit is contained in:
Pascal Precht 2022-06-15 18:28:47 +02:00 committed by r4bbit.eth
parent 882c0dcc2b
commit e0c11ae261
5 changed files with 16 additions and 2 deletions

View File

@ -41,6 +41,10 @@ proc init*(self: Controller) =
var args = SettingProfilePictureArgs(e)
self.delegate.emitProfilePicturesShowToChanged(args.value)
self.events.on(SIGNAL_SETTING_PROFILE_PICTURES_VISIBILITY_CHANGED) do(e: Args):
var args = SettingProfilePictureArgs(e)
self.delegate.emitProfilePicturesVisibilityChanged(args.value)
proc isMnemonicBackedUp*(self: Controller): bool =
return self.privacyService.isMnemonicBackedUp()

View File

@ -74,3 +74,6 @@ method getPasswordStrengthScore*(self: AccessInterface, password: string): int {
method emitProfilePicturesShowToChanged*(self: AccessInterface, value: int) {.base.} =
raise newException(ValueError, "No implementation available")
method emitProfilePicturesVisibilityChanged*(self: AccessInterface, value: int) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -93,6 +93,9 @@ method setProfilePicturesShowTo*(self: Module, value: int) =
method emitProfilePicturesShowToChanged*(self: Module, value: int) =
self.view.profilePicturesShowToChanged()
method emitProfilePicturesVisibilityChanged*(self: Module, value: int) =
self.view.profilePicturesVisibilityChanged()
method getProfilePicturesVisibility*(self: Module): int =
self.controller.getProfilePicturesVisibility()

View File

@ -180,7 +180,7 @@ proc toSettingsFieldDto*(jsonObj: JsonNode): SettingsFieldDto =
field.name = jsonObj["name"].getStr()
case field.name:
of KEY_PROFILE_PICTURES_SHOW_TO:
of KEY_PROFILE_PICTURES_SHOW_TO, KEY_PROFILE_PICTURES_VISIBILITY:
field.value = jsonObj["value"].getInt().intToStr
else:
field.value = jsonObj["value"].getStr()

View File

@ -22,6 +22,7 @@ const DEFAULT_FLEET* = $Fleet.Prod
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
const SIGNAL_SETTING_PROFILE_PICTURES_SHOW_TO_CHANGED* = "profilePicturesShowToChanged"
const SIGNAL_SETTING_PROFILE_PICTURES_VISIBILITY_CHANGED* = "profilePicturesVisibilityChanged"
logScope:
topics = "settings-service"
@ -35,7 +36,6 @@ type
SettingProfilePictureArgs* = ref object of Args
value*: int
QtObject:
type Service* = ref object of QObject
events: EventEmitter
@ -71,6 +71,10 @@ QtObject:
self.settings.profilePicturesShowTo = settingsfield.value.parseInt
self.events.emit(SIGNAL_SETTING_PROFILE_PICTURES_SHOW_TO_CHANGED, SettingProfilePictureArgs(value: self.settings.profilePicturesShowTo))
if settingsField.name == KEY_PROFILE_PICTURES_VISIBILITY:
self.settings.profilePicturesVisibility = settingsfield.value.parseInt
self.events.emit(SIGNAL_SETTING_PROFILE_PICTURES_VISIBILITY_CHANGED, SettingProfilePictureArgs(value: self.settings.profilePicturesVisibility))
proc saveSetting(self: Service, attribute: string, value: string | JsonNode | bool | int): bool =
try:
let response = status_settings.saveSettings(attribute, value)