From f0e238dce64a128fdb2c395451d91d0705142f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Thu, 6 Oct 2022 22:15:15 +0200 Subject: [PATCH] chore(general): Remove profile pictures visibility options From now on, if the image is available it should be displayed uncoditionally. Closes: #7609 --- .../profile_section/privacy/controller.nim | 20 ---- .../profile_section/privacy/io_interface.nim | 19 ---- .../main/profile_section/privacy/module.nim | 22 +---- .../main/profile_section/privacy/view.nim | 22 +---- .../service/settings/dto/settings.nim | 13 +-- src/app_service/service/settings/service.nim | 29 ------ .../AppLayouts/Chat/panels/UserListPanel.qml | 12 +-- .../Profile/stores/MessagingStore.qml | 11 --- .../Profile/views/MessagingView.qml | 99 ------------------- ui/imports/shared/views/chat/MessageView.qml | 12 +-- ui/imports/utils/Constants.qml | 12 --- ui/imports/utils/Global.qml | 6 -- 12 files changed, 6 insertions(+), 271 deletions(-) diff --git a/src/app/modules/main/profile_section/privacy/controller.nim b/src/app/modules/main/profile_section/privacy/controller.nim index 20da36bdd7..428b8434db 100644 --- a/src/app/modules/main/profile_section/privacy/controller.nim +++ b/src/app/modules/main/profile_section/privacy/controller.nim @@ -37,14 +37,6 @@ proc init*(self: Controller) = var args = OperationSuccessArgs(e) self.delegate.onPasswordChanged(args.success, args.errorMsg) - self.events.on(SIGNAL_SETTING_PROFILE_PICTURES_SHOW_TO_CHANGED) do(e: Args): - 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() @@ -72,18 +64,6 @@ proc setMessagesFromContactsOnly*(self: Controller, value: bool): bool = proc validatePassword*(self: Controller, password: string): bool = return self.privacyService.validatePassword(password) -proc getProfilePicturesShowTo*(self: Controller): int = - self.settingsService.getProfilePicturesShowTo() - -proc setProfilePicturesShowTo*(self: Controller, value: int): bool = - self.settingsService.saveProfilePicturesShowTo(value) - -proc getProfilePicturesVisibility*(self: Controller): int = - self.settingsService.getProfilePicturesVisibility() - -proc setProfilePicturesVisibility*(self: Controller, value: int): bool = - self.settingsService.saveProfilePicturesVisibility(value) - method getPasswordStrengthScore*(self: Controller, password, userName: string): int = return self.generalService.getPasswordStrengthScore(password, userName) diff --git a/src/app/modules/main/profile_section/privacy/io_interface.nim b/src/app/modules/main/profile_section/privacy/io_interface.nim index ca39813209..99fe77b006 100644 --- a/src/app/modules/main/profile_section/privacy/io_interface.nim +++ b/src/app/modules/main/profile_section/privacy/io_interface.nim @@ -56,24 +56,5 @@ method setMessagesFromContactsOnly*(self: AccessInterface, value: bool) {.base.} method validatePassword*(self: AccessInterface, password: string): bool {.base.} = raise newException(ValueError, "No implementation available") -method getProfilePicturesShowTo*(self: AccessInterface): int {.base.} = - raise newException(ValueError, "No implementation available") - -method setProfilePicturesShowTo*(self: AccessInterface, value: int) {.base.} = - raise newException(ValueError, "No implementation available") - -method getProfilePicturesVisibility*(self: AccessInterface): int {.base.} = - raise newException(ValueError, "No implementation available") - -method setProfilePicturesVisibility*(self: AccessInterface, value: int) {.base.} = - raise newException(ValueError, "No implementation available") - method getPasswordStrengthScore*(self: AccessInterface, password: string): int {.base.} = raise newException(ValueError, "No implementation available") - -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") - diff --git a/src/app/modules/main/profile_section/privacy/module.nim b/src/app/modules/main/profile_section/privacy/module.nim index f1ecb2453f..8d4ae74def 100644 --- a/src/app/modules/main/profile_section/privacy/module.nim +++ b/src/app/modules/main/profile_section/privacy/module.nim @@ -83,25 +83,5 @@ method setMessagesFromContactsOnly*(self: Module, value: bool) = method validatePassword*(self: Module, password: string): bool = self.controller.validatePassword(password) -method getProfilePicturesShowTo*(self: Module): int = - self.controller.getProfilePicturesShowTo() - -method setProfilePicturesShowTo*(self: Module, value: int) = - if (self.controller.setProfilePicturesShowTo(value)): - self.view.profilePicturesShowToChanged() - -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() - -method setProfilePicturesVisibility*(self: Module, value: int) = - if (self.controller.setProfilePicturesVisibility(value)): - self.view.profilePicturesVisibilityChanged() - method getPasswordStrengthScore*(self: Module, password: string): int = - return self.controller.getPasswordStrengthScore(password, singletonInstance.userProfile.getUsername()) \ No newline at end of file + return self.controller.getPasswordStrengthScore(password, singletonInstance.userProfile.getUsername()) diff --git a/src/app/modules/main/profile_section/privacy/view.nim b/src/app/modules/main/profile_section/privacy/view.nim index ffd16972a8..a9d3942b09 100644 --- a/src/app/modules/main/profile_section/privacy/view.nim +++ b/src/app/modules/main/profile_section/privacy/view.nim @@ -61,25 +61,5 @@ QtObject: proc validatePassword*(self: View, password: string): bool {.slot.} = self.delegate.validatePassword(password) - proc profilePicturesShowToChanged*(self: View) {.signal.} - proc getProfilePicturesShowTo*(self: View): int {.slot.} = - return self.delegate.getProfilePicturesShowTo() - QtProperty[int] profilePicturesShowTo: - read = getProfilePicturesShowTo - notify = profilePicturesShowToChanged - - proc setProfilePicturesShowTo*(self: View, value: int) {.slot.} = - self.delegate.setProfilePicturesShowTo(value) - - proc profilePicturesVisibilityChanged*(self: View) {.signal.} - proc getProfilePicturesVisibility*(self: View): int {.slot.} = - return self.delegate.getProfilePicturesVisibility() - QtProperty[int] profilePicturesVisibility: - read = getProfilePicturesVisibility - notify = profilePicturesVisibilityChanged - - proc setProfilePicturesVisibility*(self: View, value: int) {.slot.} = - self.delegate.setProfilePicturesVisibility(value) - proc getPasswordStrengthScore*(self: View, password: string): int {.slot.} = - return self.delegate.getPasswordStrengthScore(password) \ No newline at end of file + return self.delegate.getPasswordStrengthScore(password) diff --git a/src/app_service/service/settings/dto/settings.nim b/src/app_service/service/settings/dto/settings.nim index 24a2244c92..8bf15eea36 100644 --- a/src/app_service/service/settings/dto/settings.nim +++ b/src/app_service/service/settings/dto/settings.nim @@ -26,8 +26,6 @@ const KEY_SIGNING_PHRASE* = "signing-phrase" const KEY_DEFAULT_SYNC_PERIOD* = "default-sync-period" const KEY_SEND_PUSH_NOTIFICATIONS* = "send-push-notifications?" const KEY_APPEARANCE* = "appearance" -const KEY_PROFILE_PICTURES_SHOW_TO* = "profile-pictures-show-to" -const KEY_PROFILE_PICTURES_VISIBILITY* = "profile-pictures-visibility" const KEY_USE_MAILSERVERS* = "use-mailservers?" const KEY_WALLET_ROOT_ADDRESS* = "wallet-root-address" const KEY_SEND_STATUS_UPDATES* = "send-status-updates?" @@ -115,8 +113,6 @@ type defaultSyncPeriod*: int sendPushNotifications*: bool appearance*: int - profilePicturesShowTo*: int - profilePicturesVisibility*: int useMailservers*: bool walletRootAddress*: string sendStatusUpdates*: bool @@ -151,12 +147,7 @@ proc toCurrentUserStatus*(jsonObj: JsonNode): CurrentUserStatus = proc toSettingsFieldDto*(jsonObj: JsonNode): SettingsFieldDto = var field = SettingsFieldDto() field.name = jsonObj["name"].getStr() - - case field.name: - of KEY_PROFILE_PICTURES_SHOW_TO, KEY_PROFILE_PICTURES_VISIBILITY: - field.value = jsonObj["value"].getInt().intToStr - else: - field.value = jsonObj["value"].getStr() + field.value = jsonObj["value"].getStr() result = field proc toSettingsDto*(jsonObj: JsonNode): SettingsDto = @@ -181,8 +172,6 @@ proc toSettingsDto*(jsonObj: JsonNode): SettingsDto = discard jsonObj.getProp(KEY_DEFAULT_SYNC_PERIOD, result.defaultSyncPeriod) discard jsonObj.getProp(KEY_SEND_PUSH_NOTIFICATIONS, result.sendPushNotifications) discard jsonObj.getProp(KEY_APPEARANCE, result.appearance) - discard jsonObj.getProp(KEY_PROFILE_PICTURES_SHOW_TO, result.profilePicturesShowTo) - discard jsonObj.getProp(KEY_PROFILE_PICTURES_VISIBILITY, result.profilePicturesVisibility) discard jsonObj.getProp(KEY_USE_MAILSERVERS, result.useMailservers) discard jsonObj.getProp(KEY_WALLET_ROOT_ADDRESS, result.walletRootAddress) discard jsonObj.getProp(KEY_SEND_STATUS_UPDATES, result.sendStatusUpdates) diff --git a/src/app_service/service/settings/service.nim b/src/app_service/service/settings/service.nim index f23d8a2628..1db5008358 100644 --- a/src/app_service/service/settings/service.nim +++ b/src/app_service/service/settings/service.nim @@ -21,8 +21,6 @@ const DEFAULT_TELEMETRY_SERVER_URL* = "https://telemetry.status.im" const DEFAULT_FLEET* = $Fleet.StatusProd 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" @@ -66,15 +64,6 @@ QtObject: if receivedData.settings.len > 0: for settingsField in receivedData.settings: - - if settingsField.name == KEY_PROFILE_PICTURES_SHOW_TO: - 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)) - if settingsField.name == KEY_CURRENCY: self.settings.currency = settingsField.value @@ -286,24 +275,6 @@ QtObject: proc getAppearance*(self: Service): int = self.settings.appearance - proc saveProfilePicturesShowTo*(self: Service, value: int): bool = - if(self.saveSetting(KEY_PROFILE_PICTURES_SHOW_TO, value)): - self.settings.profilePicturesShowTo = value - return true - return false - - proc getProfilePicturesShowTo*(self: Service): int = - self.settings.profilePicturesShowTo - - proc saveProfilePicturesVisibility*(self: Service, value: int): bool = - if(self.saveSetting(KEY_PROFILE_PICTURES_VISIBILITY, value)): - self.settings.profilePicturesVisibility = value - return true - return false - - proc getProfilePicturesVisibility*(self: Service): int = - self.settings.profilePicturesVisibility - proc saveUseMailservers*(self: Service, value: bool): bool = if(self.saveSetting(KEY_USE_MAILSERVERS, value)): self.settings.useMailservers = value diff --git a/ui/app/AppLayouts/Chat/panels/UserListPanel.qml b/ui/app/AppLayouts/Chat/panels/UserListPanel.qml index 27cfffed14..99148db8d5 100644 --- a/ui/app/AppLayouts/Chat/panels/UserListPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/UserListPanel.qml @@ -87,17 +87,7 @@ Item { isVerified: model.isVerified isUntrustworthy: model.isUntrustworthy isAdmin: model.isAdmin - asset.name: { - const isCurrentUser = model.pubKey === root.rootStore.getPubkey() - const visibility = Global.privacyModuleInst.profilePicturesVisibility - - if (isCurrentUser - || visibility === Constants.profilePicturesVisibility.everyone - || (visibility === Constants.profilePicturesVisibility.contactsOnly && model.isContact)) - return model.icon - - return "" - } + asset.name: model.icon asset.isImage: (asset.name !== "") asset.isLetterIdenticon: (asset.name === "") asset.color: Utils.colorForColorId(model.colorId) diff --git a/ui/app/AppLayouts/Profile/stores/MessagingStore.qml b/ui/app/AppLayouts/Profile/stores/MessagingStore.qml index 67b8dabbbd..a39daeada6 100644 --- a/ui/app/AppLayouts/Profile/stores/MessagingStore.qml +++ b/ui/app/AppLayouts/Profile/stores/MessagingStore.qml @@ -7,9 +7,6 @@ QtObject { property var privacyModule property var syncModule - property int profilePicturesVisibility: privacyModule.profilePicturesVisibility - property int profilePicturesShowTo: privacyModule.profilePicturesShowTo - property var mailservers: syncModule.model property bool useMailservers: syncModule.useMailservers @@ -44,12 +41,4 @@ QtObject { function getLinkPreviewWhitelist() { return root.privacyModule.getLinkPreviewWhitelist() } - - function setProfilePicturesVisibility(value) { - return root.privacyModule.setProfilePicturesVisibility(value) - } - - function setProfilePicturesShowTo(value) { - return root.privacyModule.setProfilePicturesShowTo(value) - } } diff --git a/ui/app/AppLayouts/Profile/views/MessagingView.qml b/ui/app/AppLayouts/Profile/views/MessagingView.qml index b885a27d06..a63d26e66d 100644 --- a/ui/app/AppLayouts/Profile/views/MessagingView.qml +++ b/ui/app/AppLayouts/Profile/views/MessagingView.qml @@ -71,105 +71,6 @@ SettingsContentBase { } } - // SHOW PROFILE PICTURE TO - StatusBaseText { - Layout.fillWidth: true - Layout.leftMargin: Style.current.padding - Layout.rightMargin: Style.current.padding - text: qsTr("Show My Profile Picture To") - font.pixelSize: 15 - color: Theme.palette.directColor1 - } - - SettingsRadioButton { - Layout.fillWidth: true - Layout.leftMargin: Style.current.padding - Layout.rightMargin: Style.current.padding - label: qsTr("Everyone") - group: showProfilePictureToGroup - checked: root.messagingStore.profilePicturesShowTo === - Constants.profilePicturesShowTo.everyone - onClicked: root.messagingStore.setProfilePicturesShowTo( - Constants.profilePicturesShowTo.everyone - ) - } - - SettingsRadioButton { - Layout.fillWidth: true - Layout.leftMargin: Style.current.padding - Layout.rightMargin: Style.current.padding - label: qsTr("Contacts") - group: showProfilePictureToGroup - checked: root.messagingStore.profilePicturesShowTo === - Constants.profilePicturesShowTo.contactsOnly - onClicked: root.messagingStore.setProfilePicturesShowTo( - Constants.profilePicturesShowTo.contactsOnly - ) - } - - SettingsRadioButton { - Layout.fillWidth: true - Layout.leftMargin: Style.current.padding - Layout.rightMargin: Style.current.padding - label: qsTr("No One") - group: showProfilePictureToGroup - checked: root.messagingStore.profilePicturesShowTo === - Constants.profilePicturesShowTo.noOne - onClicked: root.messagingStore.setProfilePicturesShowTo( - Constants.profilePicturesShowTo.noOne - ) - } - - // SEE PROFILTE PICTURES FROM - StatusBaseText { - Layout.topMargin: Constants.settingsSection.itemSpacing - Layout.fillWidth: true - Layout.leftMargin: Style.current.padding - Layout.rightMargin: Style.current.padding - text: qsTr("See Profile Pictures From") - font.pixelSize: 15 - color: Theme.palette.directColor1 - } - - SettingsRadioButton { - Layout.fillWidth: true - Layout.leftMargin: Style.current.padding - Layout.rightMargin: Style.current.padding - label: qsTr("Everyone") - group: seeProfilePicturesFromGroup - checked: root.messagingStore.profilePicturesVisibility === - Constants.profilePicturesVisibility.everyone - onClicked: root.messagingStore.setProfilePicturesVisibility( - Constants.profilePicturesVisibility.everyone - ) - } - - SettingsRadioButton { - Layout.fillWidth: true - Layout.leftMargin: Style.current.padding - Layout.rightMargin: Style.current.padding - label: qsTr("Contacts") - group: seeProfilePicturesFromGroup - checked: root.messagingStore.profilePicturesVisibility === - Constants.profilePicturesVisibility.contactsOnly - onClicked: root.messagingStore.setProfilePicturesVisibility( - Constants.profilePicturesVisibility.contactsOnly - ) - } - - SettingsRadioButton { - Layout.fillWidth: true - Layout.leftMargin: Style.current.padding - Layout.rightMargin: Style.current.padding - label: qsTr("No One") - group: seeProfilePicturesFromGroup - checked: root.messagingStore.profilePicturesVisibility === - Constants.profilePicturesVisibility.noOne - onClicked: root.messagingStore.setProfilePicturesVisibility( - Constants.profilePicturesVisibility.noOne - ) - } - // Open Message Links With StatusBaseText { Layout.topMargin: Constants.settingsSection.itemSpacing diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 5e5ed2d927..d004ad538e 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -47,14 +47,6 @@ Loader { property bool amISender: false property bool senderIsAdded: false property int senderTrustStatus: Constants.trustStatus.unknown - readonly property string senderIconToShow: { - if ((!senderIsAdded && - Global.privacyModuleInst.profilePicturesVisibility !== - Constants.profilePicturesVisibility.everyone)) { - return "" - } - return senderIcon - } property string messageText: "" property string messageImage: "" property double messageTimestamp: 0 // We use double, because QML's int is too small @@ -158,7 +150,7 @@ Loader { messageContextMenu.selectedUserPublicKey = root.senderId messageContextMenu.selectedUserDisplayName = root.senderDisplayName - messageContextMenu.selectedUserIcon = root.senderIconToShow + messageContextMenu.selectedUserIcon = root.senderIcon messageContextMenu.imageSource = imageSource @@ -336,7 +328,7 @@ Loader { root.messageStore.getChatIcon() !== "") { return root.messageStore.getChatIcon() } - return root.senderIconToShow + return root.senderIcon } } } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 33993c3fe9..08d7d161ff 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -249,18 +249,6 @@ QtObject { readonly property int responseToMessageWithId: 262 // ModelRole.ResponseToMessageWithId } - readonly property QtObject profilePicturesVisibility: QtObject { - readonly property int contactsOnly: 1 - readonly property int everyone: 2 - readonly property int noOne: 3 - } - - readonly property QtObject profilePicturesShowTo: QtObject { - readonly property int contactsOnly: 1 - readonly property int everyone: 2 - readonly property int noOne: 3 - } - readonly property QtObject trustStatus: QtObject { readonly property int unknown: 0 readonly property int trusted: 1 diff --git a/ui/imports/utils/Global.qml b/ui/imports/utils/Global.qml index 050a64261f..b6f0db4e66 100644 --- a/ui/imports/utils/Global.qml +++ b/ui/imports/utils/Global.qml @@ -101,12 +101,6 @@ Item { } let contactDetails = Utils.getContactDetailsAsJson(pubkey) - - if (root.privacyModuleInst.profilePicturesVisibility !== - Constants.profilePicturesVisibility.everyone && !contactDetails.isAdded) { - return; - } - return contactDetails.displayIcon }