From 80b2436a11c228749e93bc96074f173d3b675924 Mon Sep 17 00:00:00 2001 From: Patryk Osmaczko Date: Wed, 16 Mar 2022 22:20:03 +0100 Subject: [PATCH 1/2] fix(@desktop): add missing visual identity elements --- .../Chat/panels/SuggestionBoxPanel.qml | 16 +- .../Chat/panels/SuggestionFilterPanel.qml | 4 +- ui/app/AppLayouts/Profile/ProfileLayout.qml | 3 + .../Profile/views/MyProfileView.qml | 247 ++++++++---------- .../shared/controls/chat/ProfileHeader.qml | 1 + 5 files changed, 134 insertions(+), 137 deletions(-) diff --git a/ui/app/AppLayouts/Chat/panels/SuggestionBoxPanel.qml b/ui/app/AppLayouts/Chat/panels/SuggestionBoxPanel.qml index a65c0211c94..080f658f5d0 100644 --- a/ui/app/AppLayouts/Chat/panels/SuggestionBoxPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/SuggestionBoxPanel.qml @@ -29,6 +29,7 @@ import StatusQ.Components 0.1 import shared 1.0 import shared.panels 1.0 +import shared.controls.chat 1.0 Rectangle { id: container @@ -200,15 +201,20 @@ Rectangle { height: 42 radius: Style.current.radius - StatusSmartIdenticon { + UserImage { id: accountImage anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: Style.current.smallPadding - image.width: 32 - image.height: 32 - image.source: model.icon - image.isIdenticon: model.isIdenticon + imageWidth: 32 + imageHeight: 32 + + name: model.name + pubkey: model.publicKey + icon: model.icon + isIdenticon: model.isIdenticon + showRing: !model.isAdded + interactive: false } StyledText { diff --git a/ui/app/AppLayouts/Chat/panels/SuggestionFilterPanel.qml b/ui/app/AppLayouts/Chat/panels/SuggestionFilterPanel.qml index f4c59f6bc02..8e3f9ed2700 100644 --- a/ui/app/AppLayouts/Chat/panels/SuggestionFilterPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/SuggestionFilterPanel.qml @@ -34,6 +34,7 @@ Item { property string ensName: model.ensName property string icon: model.icon property bool isIdenticon: model.isIdenticon + property bool isAdded: model.isAdded } } @@ -72,7 +73,8 @@ Item { alias: listItem.alias, ensName: listItem.ensName, icon: listItem.icon, - isIdenticon: listItem.isIdenticon + isIdenticon: listItem.isIdenticon, + isAdded: listItem.isAdded } if (all || isAcceptedItem(filter, item)) { filterModel.append(item) diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index f53a7cf23aa..b883634e6d2 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -50,6 +50,9 @@ StatusAppTwoPanelLayout { } MyProfileView { + Layout.fillWidth: true + Layout.fillHeight: true + profileStore: profileView.store.profileStore profileContentWidth: _internal.profileContentWidth } diff --git a/ui/app/AppLayouts/Profile/views/MyProfileView.qml b/ui/app/AppLayouts/Profile/views/MyProfileView.qml index 3c50d43b6b8..e435a3da08c 100644 --- a/ui/app/AppLayouts/Profile/views/MyProfileView.qml +++ b/ui/app/AppLayouts/Profile/views/MyProfileView.qml @@ -6,6 +6,7 @@ import utils 1.0 import shared 1.0 import shared.panels 1.0 import shared.popups 1.0 +import shared.controls.chat 1.0 import "../popups" import "../stores" @@ -15,121 +16,152 @@ import StatusQ.Core.Theme 0.1 import StatusQ.Components 0.1 import StatusQ.Controls 0.1 -Item { +ColumnLayout { id: root property ProfileStore profileStore - property int profileContentWidth clip: true - height: parent.height - Layout.fillWidth: true + spacing: 16 Item { - id: profileImgNameContainer - anchors.top: parent.top - anchors.topMargin: 64 - width: profileContentWidth - - anchors.horizontalCenter: parent.horizontalCenter - - height: this.childrenRect.height - - Item { - id: profileImgContainer - width: profileImg.width - height: profileImg.height - - RoundedImage { - id: profileImg - width: 64 - height: 64 - border.width: 1 - border.color: Style.current.border - source: root.profileStore.icon - smooth: false - antialiasing: true - } - - RoundedIcon { - source: Style.svg("pencil") - anchors.bottom: parent.bottom - anchors.bottomMargin: -3 - anchors.right: parent.right - anchors.rightMargin: -3 - width: 24 - height: 24 - border.width: 1 - border.color: Style.current.background - } + Layout.preferredHeight: 32 + Layout.fillWidth: true + } - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - Global.openChangeProfilePicPopup() - } - } - } + RowLayout { + Layout.alignment: Qt.AlignHCenter + Layout.maximumWidth: root.profileContentWidth StatusBaseText { id: profileName + text: root.profileStore.name - anchors.left: profileImgContainer.right - anchors.leftMargin: Style.current.halfPadding - anchors.top: profileImgContainer.top - anchors.topMargin: 4 font.weight: Font.Bold font.pixelSize: 20 color: Theme.palette.directColor1 } - Component { - id: displayNamePopupComponent - DisplayNamePopup { - profileStore: root.profileStore - onClosed: { - destroy() - } - } - } - StatusButton { - id: "editDisplayName" text: "Edit" - anchors.left: profileName.right - anchors.leftMargin: Style.current.halfPadding - onClicked: { - Global.openPopup(displayNamePopupComponent); - } + onClicked: Global.openPopup(displayNamePopupComponent) } - Address { - id: pubkeyText - text: root.profileStore.ensName !== "" ? root.profileStore.username : root.profileStore.pubkey - anchors.bottom: profileImgContainer.bottom - anchors.left: profileName.left - anchors.bottomMargin: 4 - width: 200 - font.pixelSize: 15 + Item { + Layout.fillWidth: true } StatusFlatRoundButton { id: qrCodeButton - width: 32 - height: 32 - anchors.right: parent.right - anchors.verticalCenter: profileImgContainer.verticalCenter + + Layout.preferredWidth: 32 + Layout.preferredHeight: 32 + icon.name: "qr" type: StatusFlatRoundButton.Type.Quaternary onClicked: qrCodePopup.open() } + } + + Separator { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: root.profileContentWidth + } + + ProfileHeader { + id: profileImgNameContainer + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: root.profileContentWidth + + displayName: profileStore.name + pubkey: profileStore.pubkey + icon: profileStore.icon + isIdenticon: profileStore.isIdenticon + + displayNameVisible: false + pubkeyVisible: false - Separator { - id: lineSeparator - anchors.top: profileImgContainer.bottom - anchors.topMargin: 36 + imageWidth: 80 + imageHeight: 80 + emojiSize: "20x20" + + imageOverlay: Item { + StatusFlatRoundButton { + width: 24 + height: 24 + + anchors { + right: parent.right + bottom: parent.bottom + rightMargin: -8 + } + + type: StatusFlatRoundButton.Type.Secondary + icon.name: "pencil" + icon.color: Theme.palette.directColor1 + icon.width: 12.5 + icon.height: 12.5 + + onClicked: Global.openChangeProfilePicPopup() + } + } + } + + StatusDescriptionListItem { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: root.profileContentWidth + + title: qsTr("ENS username") + subTitle: root.profileStore.ensName + tooltip.text: qsTr("Copy to clipboard") + icon.name: "copy" + visible: !!root.profileStore.ensName + iconButton.onClicked: { + root.profileStore.copyToClipboard(root.profileStore.ensName) + tooltip.visible = !tooltip.visible + } + } + + StatusDescriptionListItem { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: root.profileContentWidth + + title: qsTr("Chat key") + subTitle: root.profileStore.pubkey + subTitleComponent.elide: Text.ElideMiddle + subTitleComponent.width: 320 + subTitleComponent.font.family: Theme.palette.monoFont.name + tooltip.text: qsTr("Copy to clipboard") + icon.name: "copy" + iconButton.onClicked: { + root.profileStore.copyToClipboard(root.profileStore.pubkey) + tooltip.visible = !tooltip.visible + } + } + + StatusDescriptionListItem { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: root.profileContentWidth + + title: qsTr("Share Profile URL") + subTitle: `${Constants.userLinkPrefix}${root.profileStore.ensName !== "" ? root.profileStore.ensName : (root.profileStore.pubkey.substring(0, 5) + "..." + root.profileStore.pubkey.substring(root.profileStore.pubkey.length - 5))}` + tooltip.text: qsTr("Copy to clipboard") + icon.name: "copy" + iconButton.onClicked: { + root.profileStore.copyToClipboard(Constants.userLinkPrefix + (root.profileStore.ensName !== "" ? root.profileStore.ensName : root.profileStore.pubkey)) + tooltip.visible = !tooltip.visible + } + } + + Component { + id: displayNamePopupComponent + DisplayNamePopup { + profileStore: root.profileStore + onClosed: { + destroy() + } } } @@ -150,52 +182,5 @@ Item { smooth: false } } - - Column { - anchors.right: profileImgNameContainer.right - anchors.left: profileImgNameContainer.left - anchors.top: profileImgNameContainer.bottom - anchors.topMargin: 16 - - StatusDescriptionListItem { - title: qsTr("ENS username") - subTitle: root.profileStore.ensName - tooltip.text: qsTr("Copy to clipboard") - icon.name: "copy" - visible: !!root.profileStore.ensName - iconButton.onClicked: { - root.profileStore.copyToClipboard(root.profileStore.ensName) - tooltip.visible = !tooltip.visible - } - width: parent.width - } - - StatusDescriptionListItem { - title: qsTr("Chat key") - subTitle: root.profileStore.pubkey - subTitleComponent.elide: Text.ElideMiddle - subTitleComponent.width: 320 - subTitleComponent.font.family: Theme.palette.monoFont.name - tooltip.text: qsTr("Copy to clipboard") - icon.name: "copy" - iconButton.onClicked: { - root.profileStore.copyToClipboard(root.profileStore.pubkey) - tooltip.visible = !tooltip.visible - } - width: parent.width - } - - StatusDescriptionListItem { - title: qsTr("Share Profile URL") - subTitle: `${Constants.userLinkPrefix}${root.profileStore.ensName !== "" ? root.profileStore.ensName : (root.profileStore.pubkey.substring(0, 5) + "..." + root.profileStore.pubkey.substring(root.profileStore.pubkey.length - 5))}` - tooltip.text: qsTr("Copy to clipboard") - icon.name: "copy" - iconButton.onClicked: { - root.profileStore.copyToClipboard(Constants.userLinkPrefix + (root.profileStore.ensName !== "" ? root.profileStore.ensName : root.profileStore.pubkey)) - tooltip.visible = !tooltip.visible - } - width: parent.width - } - } } diff --git a/ui/imports/shared/controls/chat/ProfileHeader.qml b/ui/imports/shared/controls/chat/ProfileHeader.qml index a6ed328e1a9..546cb97081c 100644 --- a/ui/imports/shared/controls/chat/ProfileHeader.qml +++ b/ui/imports/shared/controls/chat/ProfileHeader.qml @@ -27,6 +27,7 @@ Item { signal clicked() height: visible ? contentContainer.height : 0 + implicitHeight: contentContainer.implicitHeight ColumnLayout { id: contentContainer From bf6fc74334fe8bcca206d9a5b63bca16f16351a0 Mon Sep 17 00:00:00 2001 From: Patryk Osmaczko Date: Thu, 17 Mar 2022 11:28:38 +0100 Subject: [PATCH 2/2] fix(@desktop): make get(Emoji/Color)Hash global utility Removed instances of VisualIdentityService as it was stateless. Removed (emoji/color)Hash models as they were reduntant, hashes are obtained only from global utility now. --- src/app/boot/app_controller.nim | 10 +--- src/app/global/utils.nim | 7 +++ .../main/chat_section/chat_content/module.nim | 5 +- .../chat_content/users/controller.nim | 11 +--- .../users/controller_interface.nim | 7 --- .../chat_content/users/module.nim | 13 +---- src/app/modules/main/chat_section/module.nim | 32 +++++------ .../module_access_interface.nim | 4 +- .../modules/main/communities/controller.nim | 10 ---- .../main/communities/controller_interface.nim | 7 --- src/app/modules/main/communities/module.nim | 8 +-- src/app/modules/main/controller.nim | 13 ----- src/app/modules/main/controller_interface.nim | 7 --- src/app/modules/main/module.nim | 26 ++------- .../module_access_interface.nim | 5 +- .../module_controller_delegate_interface.nim | 3 +- .../module_view_delegate_interface.nim | 6 --- src/app/modules/main/view.nim | 8 --- .../modules/shared_models/color_hash_item.nim | 23 -------- .../shared_models/color_hash_model.nim | 53 ------------------- .../modules/shared_models/emojis_model.nim | 42 --------------- src/app/modules/shared_models/user_item.nim | 19 ------- src/app/modules/shared_models/user_model.nim | 8 --- .../service/visual_identity/service.nim | 26 ++++----- .../visual_identity/service_interface.nim | 15 ------ ui/imports/utils/Utils.qml | 4 +- 26 files changed, 50 insertions(+), 322 deletions(-) delete mode 100644 src/app/modules/shared_models/color_hash_item.nim delete mode 100644 src/app/modules/shared_models/color_hash_model.nim delete mode 100644 src/app/modules/shared_models/emojis_model.nim delete mode 100644 src/app_service/service/visual_identity/service_interface.nim diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index 8553e9ffcd6..cb4fac0f446 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -30,7 +30,6 @@ import ../../app_service/service/devices/service as devices_service import ../../app_service/service/mailservers/service as mailservers_service import ../../app_service/service/gif/service as gif_service import ../../app_service/service/ens/service as ens_service -import ../../app_service/service/visual_identity/service as visual_identity_service import ../modules/startup/module as startup_module import ../modules/main/module as main_module @@ -84,7 +83,6 @@ type nodeService: node_service.Service gifService: gif_service.Service ensService: ens_service.Service - visualIdentityService: visual_identity_service.Service # Modules startupModule: startup_module.AccessInterface @@ -181,7 +179,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = result.settingsService, result.walletAccountService, result.transactionService, result.ethService, result.networkService, result.tokenService) result.providerService = provider_service.newService(result.ensService) - result.visualIdentityService = visual_identity_service.newService() # Modules result.startupModule = startup_module.newModule[AppController]( @@ -222,7 +219,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = result.gifService, result.ensService, result.networkService, - result.visualIdentityService ) # Do connections @@ -271,7 +267,6 @@ proc delete*(self: AppController) = self.generalService.delete self.ensService.delete self.gifService.delete - self.visualIdentityService.delete proc startupDidLoad*(self: AppController) = singletonInstance.engine.setRootContextProperty("localAppSettings", self.localAppSettingsVariant) @@ -320,14 +315,14 @@ proc load(self: AppController) = self.gifService.init() singletonInstance.engine.setRootContextProperty("globalUtils", self.globalUtilsVariant) - + let pubKey = self.settingsService.getPublicKey() singletonInstance.localAccountSensitiveSettings.setFileName(pubKey) singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant) self.buildAndRegisterLocalAccountSensitiveSettings() self.buildAndRegisterUserProfile() - + self.networkService.init() self.tokenService.init() self.walletAccountService.init() @@ -342,7 +337,6 @@ proc load(self: AppController) = self.messageService, self.gifService, self.mailserversService, - self.visualIdentityService, ) proc userLoggedIn*(self: AppController) = diff --git a/src/app/global/utils.nim b/src/app/global/utils.nim index be787b5f2e9..1bbe28f9b37 100644 --- a/src/app/global/utils.nim +++ b/src/app/global/utils.nim @@ -5,6 +5,7 @@ import ./utils/qrcodegen # Services as instances shouldn't be used in this class, just some general/global procs import ../../app_service/common/conversion import ../../app_service/service/accounts/service as procs_from_accounts +import ../../app_service/service/visual_identity/service as procs_from_visual_identity_service QtObject: @@ -128,3 +129,9 @@ QtObject: proc plainText*(self: Utils, text: string): string {.slot.} = result = plain_text(text) + + proc getEmojiHashAsJson*(self: Utils, publicKey: string): string {.slot.} = + procs_from_visual_identity_service.getEmojiHashAsJson(publicKey) + + proc getColorHashAsJson*(self: Utils, publicKey: string): string {.slot.} = + procs_from_visual_identity_service.getColorHashAsJson(publicKey) diff --git a/src/app/modules/main/chat_section/chat_content/module.nim b/src/app/modules/main/chat_section/chat_content/module.nim index 8f9f0023fc6..8668092ca92 100644 --- a/src/app/modules/main/chat_section/chat_content/module.nim +++ b/src/app/modules/main/chat_section/chat_content/module.nim @@ -20,7 +20,6 @@ import ../../../../../app_service/service/community/service as community_service import ../../../../../app_service/service/gif/service as gif_service import ../../../../../app_service/service/message/service as message_service import ../../../../../app_service/service/mailservers/service as mailservers_service -import ../../../../../app_service/service/visual_identity/service as visual_identity_service export io_interface @@ -42,7 +41,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.ServiceInterface, contactService: contact_service.Service, chatService: chat_service.Service, communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service, - mailserversService: mailservers_service.Service, visualIdentityService: visual_identity_service.Service): + mailserversService: mailservers_service.Service): Module = result = Module() result.delegate = delegate @@ -57,7 +56,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt contactService, communityService, chatService, messageService, mailserversService) result.usersModule = users_module.newModule( result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable, - contactService, chat_service, communityService, messageService, visualIdentityService + contactService, chat_service, communityService, messageService ) method delete*(self: Module) = diff --git a/src/app/modules/main/chat_section/chat_content/users/controller.nim b/src/app/modules/main/chat_section/chat_content/users/controller.nim index db6afdc917f..8f67d2344d7 100644 --- a/src/app/modules/main/chat_section/chat_content/users/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/users/controller.nim @@ -6,7 +6,6 @@ import ../../../../../../app_service/service/contacts/service as contact_service import ../../../../../../app_service/service/community/service as community_service import ../../../../../../app_service/service/message/service as message_service import ../../../../../../app_service/service/chat/service as chat_service -import ../../../../../../app_service/service/visual_identity/service as visual_identity_service import ../../../../../core/eventemitter @@ -24,13 +23,12 @@ type chatService: chat_service.Service communityService: community_service.Service messageService: message_service.Service - visualIdentityService: visual_identity_service.Service proc newController*( delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string, belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service, chatService: chat_service.Service, communityService: community_service.Service, - messageService: message_service.Service, visualIdentityService: visual_identity_service.Service + messageService: message_service.Service ): Controller = result = Controller() result.delegate = delegate @@ -44,7 +42,6 @@ proc newController*( result.communityService = communityService result.messageService = messageService result.chatService = chatService - result.visualIdentityService = visualIdentityService method delete*(self: Controller) = discard @@ -155,9 +152,3 @@ method getContactDetails*(self: Controller, contactId: string): ContactDetails = method getStatusForContact*(self: Controller, contactId: string): StatusUpdateDto = return self.contactService.getStatusForContactWithId(contactId) - -method getEmojiHash*(self: Controller, pubkey: string): EmojiHashDto = - return self.visual_identity_service.emojiHashOf(pubkey) - -method getColorHash*(self: Controller, pubkey: string): ColorHashDto = - return self.visual_identity_service.colorHashOf(pubkey) diff --git a/src/app/modules/main/chat_section/chat_content/users/controller_interface.nim b/src/app/modules/main/chat_section/chat_content/users/controller_interface.nim index 0bc7593537e..e3eb656d462 100644 --- a/src/app/modules/main/chat_section/chat_content/users/controller_interface.nim +++ b/src/app/modules/main/chat_section/chat_content/users/controller_interface.nim @@ -1,6 +1,5 @@ import ../../../../../../app_service/service/contacts/service as contacts_service import ../../../../../../app_service/service/chat/service as chat_service -import ../../../../../../app_service/service/visual_identity/service type AccessInterface* {.pure inheritable.} = ref object of RootObj @@ -33,9 +32,3 @@ method getChat*(self: AccessInterface): ChatDto {.base.} = method getChatMemberInfo*(self: AccessInterface, id: string): (bool, bool) = raise newException(ValueError, "No implementation available") - -method getEmojiHash*(self: AccessInterface, pubkey: string): EmojiHashDto {.base.} = - raise newException(ValueError, "No implementation available") - -method getColorHash*(self: AccessInterface, pubkey: string): ColorHashDto {.base.} = - raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/chat_content/users/module.nim b/src/app/modules/main/chat_section/chat_content/users/module.nim index eea8a99b9df..2932feff3ea 100644 --- a/src/app/modules/main/chat_section/chat_content/users/module.nim +++ b/src/app/modules/main/chat_section/chat_content/users/module.nim @@ -9,7 +9,6 @@ import ../../../../../../app_service/service/contacts/service as contact_service import ../../../../../../app_service/service/chat/service as chat_service import ../../../../../../app_service/service/community/service as community_service import ../../../../../../app_service/service/message/service as message_service -import ../../../../../../app_service/service/visual_identity/service as visual_identity_service export io_interface @@ -25,7 +24,7 @@ proc newModule*( delegate: delegate_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string, belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service, chatService: chat_service.Service, communityService: community_service.Service, - messageService: message_service.Service, visualIdentityService: visual_identity_service.Service + messageService: message_service.Service, ): Module = result = Module() result.delegate = delegate @@ -33,7 +32,7 @@ proc newModule*( result.viewVariant = newQVariant(result.view) result.controller = controller.newController( result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable, - contactService, chatService, communityService, messageService, visualIdentityService + contactService, chatService, communityService, messageService, ) result.moduleLoaded = false @@ -63,8 +62,6 @@ method viewDidLoad*(self: Module) = singletonInstance.userProfile.getIcon(), singletonInstance.userProfile.getIdenticon(), singletonInstance.userProfile.getIsIdenticon(), - self.controller.getEmojiHash(singletonInstance.userProfile.getPubKey()), - self.controller.getColorHash(singletonInstance.userProfile.getPubKey()), isAdded = true, admin, joined, @@ -90,8 +87,6 @@ method viewDidLoad*(self: Module) = contactDetails.icon, contactDetails.details.identicon, contactDetails.isidenticon, - self.controller.getEmojiHash(publicKey), - self.controller.getColorHash(publicKey), contactDetails.details.added, admin, joined @@ -125,8 +120,6 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto]) = contactDetails.icon, contactDetails.details.identicon, contactDetails.isidenticon, - self.controller.getEmojiHash(m.`from`), - self.controller.getColorHash(m.`from`), contactDetails.details.added, )) @@ -180,8 +173,6 @@ method onChatMembersAdded*(self: Module, ids: seq[string]) = contactDetails.icon, contactDetails.details.identicon, contactDetails.isidenticon, - self.controller.getEmojiHash(id), - self.controller.getColorHash(id), contactDetails.details.added, admin, joined diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 1bb54724320..d3c6d6e35af 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -19,7 +19,6 @@ import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/message/service as message_service import ../../../../app_service/service/mailservers/service as mailservers_service import ../../../../app_service/service/gif/service as gif_service -import ../../../../app_service/service/visual_identity/service as visual_identity_service export io_interface @@ -86,11 +85,10 @@ proc addSubmodule(self: Module, chatId: string, belongToCommunity: bool, isUsers communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service, - mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service) = + mailserversService: mailservers_service.Service) = self.chatContentModules[chatId] = chat_content_module.newModule(self, events, self.controller.getMySectionId(), chatId, belongToCommunity, isUsersListAvailable, settingsService, contactService, chatService, communityService, - messageService, gifService, mailserversService, visualIdentityService) + messageService, gifService, mailserversService) proc removeSubmodule(self: Module, chatId: string) = if(not self.chatContentModules.contains(chatId)): @@ -104,8 +102,7 @@ proc buildChatUI(self: Module, events: EventEmitter, communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service, - mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service) = + mailserversService: mailservers_service.Service) = let types = @[ChatType.OneToOne, ChatType.Public, ChatType.PrivateGroupChat] let chats = self.controller.getChatDetailsForChatTypes(types) @@ -133,7 +130,7 @@ proc buildChatUI(self: Module, events: EventEmitter, active=false, c.position, c.categoryId) self.view.chatsModel().appendItem(item) self.addSubmodule(c.id, false, isUsersListAvailable, events, settingsService, contactService, chatService, - communityService, messageService, gifService, mailserversService, visualIdentityService) + communityService, messageService, gifService, mailserversService) # make the first Public chat active when load the app if(selectedItemId.len == 0 and c.chatType == ChatType.Public): @@ -148,8 +145,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter, communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service, - mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service) = + mailserversService: mailservers_service.Service) = var selectedItemId = "" var selectedSubItemId = "" let communities = self.controller.getJoinedCommunities() @@ -170,7 +166,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter, notificationsCount, chatDto.muted, blocked=false, active = false, c.position, c.categoryId) self.view.chatsModel().appendItem(channelItem) self.addSubmodule(chatDto.id, true, true, events, settingsService, contactService, chatService, communityService, - messageService, gifService, mailserversService, visualIdentityService) + messageService, gifService, mailserversService) # make the first channel which doesn't belong to any category active when load the app if(selectedItemId.len == 0): @@ -201,7 +197,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter, active=false, c.position) categoryChannels.add(channelItem) self.addSubmodule(chatDto.id, true, true, events, settingsService, contactService, chatService, communityService, - messageService, gifService, mailserversService, visualIdentityService) + messageService, gifService, mailserversService) # in case there is no channels beyond categories, # make the first channel of the first category active when load the app @@ -266,15 +262,14 @@ method load*(self: Module, events: EventEmitter, communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service, - mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service) = + mailserversService: mailservers_service.Service) = self.controller.init() self.view.load() if(self.controller.isCommunity()): - self.buildCommunityUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService) + self.buildCommunityUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService) else: - self.buildChatUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService) + self.buildChatUI(events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService) self.initContactRequestsModel() # we do this only in case of chat section (not in case of communities) for cModule in self.chatContentModules.values: @@ -405,7 +400,6 @@ method addNewChat*( messageService: message_service.Service, gifService: gif_service.Service, mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service, setChatAsActive: bool = true) = let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0 let notificationsCount = chatDto.unviewedMentionsCount @@ -427,7 +421,7 @@ method addNewChat*( chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, blocked=false, active=false, position = 0, chatDto.categoryId, chatDto.highlight) self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService, - communityService, messageService, gifService, mailserversService, visualIdentityService) + communityService, messageService, gifService, mailserversService) self.chatContentModules[chatDto.id].load() self.view.chatsModel().appendItem(item) if setChatAsActive: @@ -443,7 +437,7 @@ method addNewChat*( amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, blocked=false, active=false, chatDto.position) self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService, - communityService, messageService, gifService, mailserversService, visualIdentityService) + communityService, messageService, gifService, mailserversService) self.chatContentModules[chatDto.id].load() categoryItem.appendSubItem(channelItem) if setChatAsActive: @@ -558,7 +552,7 @@ method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) = method onCommunityChannelEdited*(self: Module, chat: ChatDto) = if(not self.chatContentModules.contains(chat.id)): return - self.view.chatsModel().updateItemDetails(chat.id, chat.name, chat.description, chat.emoji, + self.view.chatsModel().updateItemDetails(chat.id, chat.name, chat.description, chat.emoji, chat.color) method createOneToOneChat*(self: Module, communityID: string, chatId: string, ensName: string) = diff --git a/src/app/modules/main/chat_section/private_interfaces/module_access_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_access_interface.nim index d62eaf37e91..4912fb68d18 100644 --- a/src/app/modules/main/chat_section/private_interfaces/module_access_interface.nim +++ b/src/app/modules/main/chat_section/private_interfaces/module_access_interface.nim @@ -7,7 +7,6 @@ import ../../../../../app_service/service/community/service as community_service import ../../../../../app_service/service/message/service as message_service import ../../../../../app_service/service/gif/service as gif_service import ../../../../../app_service/service/mailservers/service as mailservers_service -import ../../../../../app_service/service/visual_identity/service as visual_identity_service import ../model as chats_model @@ -23,8 +22,7 @@ method load*(self: AccessInterface, events: EventEmitter, communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service, - mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service) {.base.} = + mailserversService: mailservers_service.Service) {.base.} = raise newException(ValueError, "No implementation available") method isLoaded*(self: AccessInterface): bool {.base.} = diff --git a/src/app/modules/main/communities/controller.nim b/src/app/modules/main/communities/controller.nim index e19bf46ce5a..d3f74d5400e 100644 --- a/src/app/modules/main/communities/controller.nim +++ b/src/app/modules/main/communities/controller.nim @@ -6,7 +6,6 @@ import ../../../core/signals/types import ../../../core/eventemitter import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/contacts/service as contacts_service -import ../../../../app_service/service/visual_identity/service as visual_identity_service export controller_interface @@ -16,21 +15,18 @@ type events: EventEmitter communityService: community_service.Service contactsService: contacts_service.Service - visualIdentityService: visual_identity_service.Service proc newController*( delegate: io_interface.AccessInterface, events: EventEmitter, communityService: community_service.Service, contactsService: contacts_service.Service, - visualIdentityService: visual_identity_service.Service ): Controller = result = Controller() result.delegate = delegate result.events = events result.communityService = communityService result.contactsService = contactsService - result.visualIdentityService = visualIdentityService method delete*(self: Controller) = discard @@ -138,9 +134,3 @@ method userCanJoin*(self: Controller, communityId: string): bool = method isCommunityRequestPending*(self: Controller, communityId: string): bool = return self.communityService.isCommunityRequestPending(communityId) - -method getEmojiHash*(self: Controller, pubkey: string): EmojiHashDto = - return self.visualIdentityService.emojiHashOf(pubkey) - -method getColorHash*(self: Controller, pubkey: string): ColorHashDto = - return self.visualIdentityService.colorHashOf(pubkey) diff --git a/src/app/modules/main/communities/controller_interface.nim b/src/app/modules/main/communities/controller_interface.nim index a7c3cc845c3..be7d6ce89e0 100644 --- a/src/app/modules/main/communities/controller_interface.nim +++ b/src/app/modules/main/communities/controller_interface.nim @@ -1,6 +1,5 @@ import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/contacts/service as contacts_service -import ../../../../app_service/service/visual_identity/service as visual_identity_service type AccessInterface* {.pure inheritable.} = ref object of RootObj @@ -64,12 +63,6 @@ method getContactNameAndImage*(self: AccessInterface, contactId: string): method getContactDetails*(self: AccessInterface, contactId: string): ContactDetails {.base.} = raise newException(ValueError, "No implementation available") -method getEmojiHash*(self: AccessInterface, pubkey: string): EmojiHashDto {.base.} = - raise newException(ValueError, "No implementation available") - -method getColorHash*(self: AccessInterface, pubkey: string): ColorHashDto {.base.} = - raise newException(ValueError, "No implementation available") - type ## Abstract class (concept) which must be implemented by object/s used in this ## module. diff --git a/src/app/modules/main/communities/module.nim b/src/app/modules/main/communities/module.nim index 42458fbe3bb..57df5c15189 100644 --- a/src/app/modules/main/communities/module.nim +++ b/src/app/modules/main/communities/module.nim @@ -9,7 +9,6 @@ import ../../../global/global_singleton import ../../../core/eventemitter import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/contacts/service as contacts_service -import ../../../../app_service/service/visual_identity/service as visual_identity_service export io_interface @@ -34,9 +33,7 @@ proc newModule*( delegate: delegate_interface.AccessInterface, events: EventEmitter, communityService: community_service.Service, - contactsService: contacts_service.Service, - visualIdentityService: visual_identity_service.Service - ): Module = + contactsService: contacts_service.Service): Module = result = Module() result.delegate = delegate result.view = newView(result) @@ -46,7 +43,6 @@ proc newModule*( events, communityService, contactsService, - visualIdentityService ) result.moduleLoaded = false @@ -103,8 +99,6 @@ method getCommunityItem(self: Module, c: CommunityDto): SectionItem = contactDetails.icon, contactDetails.details.identicon, contactDetails.isidenticon, - self.controller.getEmojiHash(member.id), - self.controller.getColorHash(member.id), contactDetails.details.added, )) ) diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index f3af7f3312e..7f2abe480d0 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -16,7 +16,6 @@ import ../../../app_service/service/gif/service as gif_service import ../../../app_service/service/mailservers/service as mailservers_service import ../../../app_service/service/privacy/service as privacy_service import ../../../app_service/service/node/service as node_service -import ../../../app_service/service/visual_identity/service as visual_identity_service export controller_interface @@ -38,7 +37,6 @@ type privacyService: privacy_service.Service mailserversService: mailservers_service.Service nodeService: node_service.Service - visualIdentityService: visual_identity_service.Service activeSectionId: string proc newController*(delegate: io_interface.AccessInterface, @@ -54,7 +52,6 @@ proc newController*(delegate: io_interface.AccessInterface, privacyService: privacy_service.Service, mailserversService: mailservers_service.Service, nodeService: node_service.Service, - visualIdentityService: visual_identity_service.Service ): Controller = result = Controller() @@ -70,7 +67,6 @@ proc newController*(delegate: io_interface.AccessInterface, result.gifService = gifService result.privacyService = privacyService result.nodeService = nodeService - result.visualIdentityService = visualIdentityService method delete*(self: Controller) = discard @@ -108,7 +104,6 @@ method init*(self: Controller) = self.messageService, self.gifService, self.mailserversService, - self.visualIdentityService ) self.events.on(TOGGLE_SECTION) do(e:Args): @@ -127,7 +122,6 @@ method init*(self: Controller) = self.messageService, self.gifService, self.mailserversService, - self.visualIdentityService ) self.events.on(SIGNAL_COMMUNITY_IMPORTED) do(e:Args): @@ -144,7 +138,6 @@ method init*(self: Controller) = self.messageService, self.gifService, self.mailserversService, - self.visualIdentityService ) self.events.on(SIGNAL_COMMUNITY_LEFT) do(e:Args): @@ -293,9 +286,3 @@ method switchTo*(self: Controller, sectionId, chatId, messageId: string) = method getCommunityById*(self: Controller, communityId: string): CommunityDto = return self.communityService.getCommunityById(communityId) - -method getEmojiHash*(self: Controller, pubkey: string): EmojiHashDto = - return self.visualIdentityService.emojiHashOf(pubkey) - -method getColorHash*(self: Controller, pubkey: string): ColorHashDto = - return self.visualIdentityService.colorHashOf(pubkey) diff --git a/src/app/modules/main/controller_interface.nim b/src/app/modules/main/controller_interface.nim index 6d4391d8b04..985623a7783 100644 --- a/src/app/modules/main/controller_interface.nim +++ b/src/app/modules/main/controller_interface.nim @@ -2,7 +2,6 @@ import ../shared_models/section_item import ../../../app_service/service/contacts/dto/contact_details as contact_details import ../../../app_service/service/contacts/dto/contacts as contacts_dto import ../../../app_service/service/community/service as community_service -import ../../../app_service/service/visual_identity/service as visual_identity_service type AccessInterface* {.pure inheritable.} = ref object of RootObj @@ -66,9 +65,3 @@ method getCommunityById*(self: AccessInterface, communityId: string): CommunityD method isConnected*(self: AccessInterface): bool {.base.} = raise newException(ValueError, "No implementation available") - -method getEmojiHash*(self: AccessInterface, pubkey: string): EmojiHashDto {.base.} = - raise newException(ValueError, "No implementation available") - -method getColorHash*(self: AccessInterface, pubkey: string): ColorHashDto {.base.} = - raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index decb277108e..a8739ef34c7 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -49,7 +49,6 @@ import ../../../app_service/service/mailservers/service as mailservers_service import ../../../app_service/service/gif/service as gif_service import ../../../app_service/service/ens/service as ens_service import ../../../app_service/service/network/service as network_service -import ../../../app_service/service/visual_identity/service as visual_identity_service import ../../core/notifications/details import ../../core/eventemitter @@ -109,7 +108,6 @@ proc newModule*[T]( gifService: gif_service.Service, ensService: ens_service.Service, networkService: network_service.Service, - visualIdentityService: visual_identity_service.Service ): Module[T] = result = Module[T]() result.delegate = delegate @@ -129,7 +127,6 @@ proc newModule*[T]( privacyService, mailserversService, nodeService, - visualIdentityService ) result.moduleLoaded = false @@ -152,7 +149,7 @@ proc newModule*[T]( result.stickersModule = stickers_module.newModule(result, events, stickersService, settingsService, walletAccountService) result.activityCenterModule = activity_center_module.newModule(result, events, activityCenterService, contactsService, messageService, chatService) - result.communitiesModule = communities_module.newModule(result, events, communityService, contactsService, visualIdentityService) + result.communitiesModule = communities_module.newModule(result, events, communityService, contactsService) result.appSearchModule = app_search_module.newModule(result, events, contactsService, chatService, communityService, messageService) result.nodeSectionModule = node_section_module.newModule(result, events, settingsService, nodeService, nodeConfigurationService) @@ -213,8 +210,6 @@ proc createCommunityItem[T](self: Module[T], c: CommunityDto): SectionItem = contactDetails.icon, contactDetails.details.identicon, contactDetails.isidenticon, - self.controller.getEmojiHash(member.id), - self.controller.getColorHash(member.id), contactDetails.details.added )), c.pendingRequestsToJoin.map(x => pending_request_item.initItem( @@ -237,7 +232,6 @@ method load*[T]( messageService: message_service.Service, gifService: gif_service.Service, mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service ) = singletonInstance.engine.setRootContextProperty("mainModule", self.viewVariant) self.controller.init() @@ -353,9 +347,9 @@ method load*[T]( activeSection = profileSettingsSectionItem # Load all sections - self.chatSectionModule.load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService) + self.chatSectionModule.load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService) for cModule in self.communitySectionsModule.values: - cModule.load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService) + cModule.load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService) self.browserSectionModule.load() # self.nodeManagementSectionModule.load() @@ -582,7 +576,6 @@ method communityJoined*[T]( messageService: message_service.Service, gifService: gif_service.Service, mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service ) = var firstCommunityJoined = false if (self.communitySectionsModule.len == 0): @@ -600,7 +593,7 @@ method communityJoined*[T]( gifService, mailserversService ) - self.communitySectionsModule[community.id].load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService, visualIdentityService) + self.communitySectionsModule[community.id].load(events, settingsService, contactsService, chatService, communityService, messageService, gifService, mailserversService) let communitySectionItem = self.createCommunityItem(community) if (firstCommunityJoined): @@ -653,17 +646,6 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string): string = } return $jsonObj -method getEmojiHashAsJson*[T](self: Module[T], publicKey: string): string = - let emojiHash = self.controller.getEmojiHash(publicKey) - return $$emojiHash - -method getColorHashAsJson*[T](self: Module[T], publicKey: string): string = - let colorHash = self.controller.getColorHash(publicKey) - let json = newJArray() - for segment in colorHash: - json.add(%* {"segmentLength": segment.len, "colorId": segment.colorIdx}) - return $json - method resolveENS*[T](self: Module[T], ensName: string, uuid: string) = if ensName.len == 0: error "error: cannot do a lookup for empty ens name" diff --git a/src/app/modules/main/private_interfaces/module_access_interface.nim b/src/app/modules/main/private_interfaces/module_access_interface.nim index 9c8d6b8b42f..d756322375b 100644 --- a/src/app/modules/main/private_interfaces/module_access_interface.nim +++ b/src/app/modules/main/private_interfaces/module_access_interface.nim @@ -5,7 +5,6 @@ import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/message/service as message_service import ../../../../app_service/service/gif/service as gif_service import ../../../../app_service/service/mailservers/service as mailservers_service -import ../../../../app_service/service/visual_identity/service as visual_identity_service import ../../../core/eventemitter @@ -21,9 +20,7 @@ method load*( communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service, - mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service - ) + mailserversService: mailservers_service.Service) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim index 20afecc6566..1d652cacd2a 100644 --- a/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim +++ b/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim @@ -23,8 +23,7 @@ method communityJoined*(self: AccessInterface, community: CommunityDto, events: communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service, - mailserversService: mailservers_service.Service, - visualIdentityService: visual_identity_service.Service) {.base.} = + mailserversService: mailservers_service.Service) {.base.} = raise newException(ValueError, "No implementation available") method communityEdited*(self: AccessInterface, community: CommunityDto) {.base.} = diff --git a/src/app/modules/main/private_interfaces/module_view_delegate_interface.nim b/src/app/modules/main/private_interfaces/module_view_delegate_interface.nim index 423a412808f..3e4225e9846 100644 --- a/src/app/modules/main/private_interfaces/module_view_delegate_interface.nim +++ b/src/app/modules/main/private_interfaces/module_view_delegate_interface.nim @@ -26,12 +26,6 @@ method getAppSearchModule*(self: AccessInterface): QVariant {.base.} = method getContactDetailsAsJson*(self: AccessInterface, publicKey: string): string {.base.} = raise newException(ValueError, "No implementation available") -method getEmojiHashAsJson*(self: AccessInterface, publicKey: string): string {.base.} = - raise newException(ValueError, "No implementation available") - -method getColorHashAsJson*(self: AccessInterface, publicKey: string): string {.base.} = - raise newException(ValueError, "No implementation available") - method resolveENS*(self: AccessInterface, ensName: string, uuid: string) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/view.nim b/src/app/modules/main/view.nim index 2978c725f1a..f28c37f4034 100644 --- a/src/app/modules/main/view.nim +++ b/src/app/modules/main/view.nim @@ -151,14 +151,6 @@ QtObject: proc getContactDetailsAsJson(self: View, publicKey: string): string {.slot.} = return self.delegate.getContactDetailsAsJson(publicKey) - # serialized return - nimqml does not allow QVariant return type in slots - proc getEmojiHashAsJson(self: View, publicKey: string): string {.slot.} = - return self.delegate.getEmojiHashAsJson(publicKey) - - # serialized return - nimqml does not allow QVariant return type in slots - proc getColorHashAsJson(self: View, publicKey: string): string {.slot.} = - return self.delegate.getColorHashAsJson(publicKey) - proc resolveENS*(self: View, ensName: string, uuid: string) {.slot.} = self.delegate.resolveENS(ensName, uuid) diff --git a/src/app/modules/shared_models/color_hash_item.nim b/src/app/modules/shared_models/color_hash_item.nim deleted file mode 100644 index 931284312bc..00000000000 --- a/src/app/modules/shared_models/color_hash_item.nim +++ /dev/null @@ -1,23 +0,0 @@ -import strformat - -type - Item* = ref object - length: int - colorIdx: int - -proc initItem*(length: int, colorIdx: int): Item = - result = Item() - result.length = length - result.colorIdx = colorIdx - -proc `$`*(self: Item): string = - result = fmt"""ColorHashItem( - length: {$self.length}, - colorIdx: {$self.colorIdx}, - ]""" - -proc length*(self: Item): int {.inline.} = - self.length - -proc colorIdx*(self: Item): int {.inline.} = - self.colorIdx diff --git a/src/app/modules/shared_models/color_hash_model.nim b/src/app/modules/shared_models/color_hash_model.nim deleted file mode 100644 index e8ce9243ad1..00000000000 --- a/src/app/modules/shared_models/color_hash_model.nim +++ /dev/null @@ -1,53 +0,0 @@ -import NimQml, Tables - -import color_hash_item - -type - ModelRole {.pure.} = enum - Length = UserRole + 1 - ColorIdx - -QtObject: - type - Model* = ref object of QAbstractListModel - items*: seq[Item] - - proc delete(self: Model) = - self.items = @[] - self.QAbstractListModel.delete - - proc setup(self: Model) = - self.QAbstractListModel.setup - - proc newModel*(): Model = - new(result, delete) - result.setup - - proc setItems*(self: Model, items: seq[Item]) = - self.beginResetModel() - self.items = items - self.endResetModel() - - method rowCount(self: Model, index: QModelIndex = nil): int = - return self.items.len - - method data(self: Model, index: QModelIndex, role: int): QVariant = - if not index.isValid: - return - if index.row < 0 or index.row >= self.items.len: - return - - let item = self.items[index.row] - let enumRole = role.ModelRole - - case enumRole: - of ModelRole.Length: - result = newQVariant(item.length) - of ModelRole.ColorIdx: - result = newQVariant(item.colorIdx) - - method roleNames(self: Model): Table[int, string] = - { - ModelRole.Length.int:"length", - ModelRole.ColorIdx.int:"colorIdx", - }.toTable diff --git a/src/app/modules/shared_models/emojis_model.nim b/src/app/modules/shared_models/emojis_model.nim deleted file mode 100644 index 34aeb472d17..00000000000 --- a/src/app/modules/shared_models/emojis_model.nim +++ /dev/null @@ -1,42 +0,0 @@ -import NimQml, Tables - -type - RoleNames {.pure.} = enum - Emoji = UserRole + 1, - -QtObject: - type - Model* = ref object of QAbstractListModel - items*: seq[string] - - proc delete(self: Model) = - self.items = @[] - self.QAbstractListModel.delete - - proc setup(self: Model) = - self.QAbstractListModel.setup - - proc newModel*(): Model = - new(result, delete) - result.setup - - proc setItems*(self: Model, items: seq[string]) = - self.beginResetModel() - self.items = items - self.endResetModel() - - proc items*(self: Model): seq[string] = - return self.items - - method rowCount(self: Model, index: QModelIndex = nil): int = - return self.items.len - - method data(self: Model, index: QModelIndex, role: int): QVariant = - if not index.isValid: - return - if index.row < 0 or index.row >= self.items.len: - return - return newQVariant(self.items[index.row]) - - method roleNames(self: Model): Table[int, string] = - { RoleNames.Emoji.int:"emoji" }.toTable diff --git a/src/app/modules/shared_models/user_item.nim b/src/app/modules/shared_models/user_item.nim index 825b46af055..4cc5bef1a22 100644 --- a/src/app/modules/shared_models/user_item.nim +++ b/src/app/modules/shared_models/user_item.nim @@ -1,7 +1,5 @@ import strformat, sequtils, sugar -import ./emojis_model, ./color_hash_model, ./color_hash_item - type OnlineStatus* {.pure.} = enum Offline = 0 @@ -10,9 +8,6 @@ type Idle Invisible -type - ColorHashSegment* = tuple[len, colorIdx: int] - # TODO add role when it is needed type Item* = ref object @@ -25,8 +20,6 @@ type icon: string identicon: string isIdenticon: bool - emojiHashModel: emojis_model.Model - colorHashModel: color_hash_model.Model isAdded: bool isAdmin: bool joined: bool @@ -41,8 +34,6 @@ proc initItem*( icon: string, identicon: string, isidenticon: bool, - emojiHash: seq[string], - colorHash: seq[ColorHashSegment], isAdded: bool = false, isAdmin: bool = false, joined: bool = false, @@ -57,10 +48,6 @@ proc initItem*( result.icon = icon result.identicon = identicon result.isIdenticon = isidenticon - result.emojiHashModel = emojis_model.newModel() - result.emojiHashModel.setItems(emojiHash) - result.colorHashModel = color_hash_model.newModel() - result.colorHashModel.setItems(map(colorHash, x => color_hash_item.initItem(x.len, x.colorIdx))) result.isAdded = isAdded result.isAdmin = isAdmin result.joined = joined @@ -145,9 +132,3 @@ proc joined*(self: Item): bool {.inline.} = proc `joined=`*(self: Item, value: bool) {.inline.} = self.joined = value - -proc emojiHashModel*(self: Item): emojis_model.Model {.inline.} = - self.emojiHashModel - -proc colorHashModel*(self: Item): color_hash_model.Model {.inline.} = - self.colorHashModel diff --git a/src/app/modules/shared_models/user_model.nim b/src/app/modules/shared_models/user_model.nim index a0c75246fd3..2501017bc11 100644 --- a/src/app/modules/shared_models/user_model.nim +++ b/src/app/modules/shared_models/user_model.nim @@ -13,8 +13,6 @@ type Icon Identicon IsIdenticon - EmojiHashModel - ColorHashModel IsAdded IsAdmin Joined @@ -68,8 +66,6 @@ QtObject: ModelRole.Icon.int:"icon", ModelRole.Identicon.int:"identicon", ModelRole.IsIdenticon.int:"isIdenticon", - ModelRole.EmojiHashModel.int:"emojiHashModel", - ModelRole.ColorHashModel.int:"colorHashModel", ModelRole.IsAdded.int:"isAdded", ModelRole.IsAdmin.int:"isAdmin", ModelRole.Joined.int:"joined", @@ -104,10 +100,6 @@ QtObject: result = newQVariant(item.identicon) of ModelRole.IsIdenticon: result = newQVariant(item.isIdenticon) - of ModelRole.EmojiHashModel: - result = newQVariant(item.emojiHashModel) - of ModelRole.ColorHashModel: - result = newQVariant(item.colorHashModel) of ModelRole.IsAdded: result = newQVariant(item.isAdded) of ModelRole.IsAdmin: diff --git a/src/app_service/service/visual_identity/service.nim b/src/app_service/service/visual_identity/service.nim index 5eacac056d9..542a311b839 100644 --- a/src/app_service/service/visual_identity/service.nim +++ b/src/app_service/service/visual_identity/service.nim @@ -1,21 +1,11 @@ -import chronicles +import chronicles, marshal, json import ./dto as dto -import ./service_interface import ../../../backend/visual_identity as status_visual_identity export dto -type - Service* = ref object of service_interface.ServiceInterface - -proc newService*(): Service = - result = Service() - -method delete*(self: Service) = - discard - -proc emojiHashOf*(self: Service, pubkey: string): EmojiHashDto = +proc emojiHashOf*(pubkey: string): EmojiHashDto = try: let response = status_visual_identity.emojiHashOf(pubkey) @@ -28,7 +18,7 @@ proc emojiHashOf*(self: Service, pubkey: string): EmojiHashDto = error "error: ", methodName = "emojiHashOf", errName = e.name, errDesription = e.msg -proc colorHashOf*(self: Service, pubkey: string): ColorHashDto = +proc colorHashOf*(pubkey: string): ColorHashDto = try: let response = status_visual_identity.colorHashOf(pubkey) @@ -40,3 +30,13 @@ proc colorHashOf*(self: Service, pubkey: string): ColorHashDto = except Exception as e: error "error: ", methodName = "colorHashOf", errName = e.name, errDesription = e.msg + +proc getEmojiHashAsJson*(publicKey: string): string = + return $$emojiHashOf(publicKey) + +proc getColorHashAsJson*(publicKey: string): string = + let colorHash = colorHashOf(publicKey) + let json = newJArray() + for segment in colorHash: + json.add(%* {"segmentLength": segment.len, "colorId": segment.colorIdx}) + return $json diff --git a/src/app_service/service/visual_identity/service_interface.nim b/src/app_service/service/visual_identity/service_interface.nim deleted file mode 100644 index 1a4ed987833..00000000000 --- a/src/app_service/service/visual_identity/service_interface.nim +++ /dev/null @@ -1,15 +0,0 @@ -import ./dto as dto -export dto - -type - ServiceInterface* {.pure inheritable.} = ref object of RootObj - ## Abstract class for this service access. - -method delete*(self: ServiceInterface) {.base.} = - raise newException(ValueError, "No implementation available") - -method emojiHashOf*(self: ServiceInterface, pubkey: string): EmojiHashDto {.base.} = - raise newException(ValueError, "No implementation available") - -method colorHashOf*(self: ServiceInterface, pubkey: string): ColorHashDto {.base.} = - raise newException(ValueError, "No implementation available") diff --git a/ui/imports/utils/Utils.qml b/ui/imports/utils/Utils.qml index cc144351dcc..0347958be81 100644 --- a/ui/imports/utils/Utils.qml +++ b/ui/imports/utils/Utils.qml @@ -608,7 +608,7 @@ QtObject { if (publicKey === "") { return "" } - let jsonObj = mainModule.getEmojiHashAsJson(publicKey) + let jsonObj = globalUtils.getEmojiHashAsJson(publicKey) return JSON.parse(jsonObj) } @@ -616,7 +616,7 @@ QtObject { if (publicKey === "") { return "" } - let jsonObj = mainModule.getColorHashAsJson(publicKey) + let jsonObj = globalUtils.getColorHashAsJson(publicKey) return JSON.parse(jsonObj) }