From 851dd3bc76b44b3106c4d1e7a2ad9087f56486e5 Mon Sep 17 00:00:00 2001 From: MishkaRogachev Date: Thu, 20 Oct 2022 15:57:41 +0400 Subject: [PATCH] =?UTF-8?q?feat(ActivityCenter):=20Review=20fixed=20for=20?= =?UTF-8?q?community=20membership=20A=D0=A1=20notifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/modules/main/activity_center/item.nim | 17 +++--- .../modules/main/activity_center/module.nim | 4 +- src/app_service/service/community/service.nim | 2 + .../StatusQ/Controls/StatusRoundButton.qml | 5 +- .../src/StatusQ/Core/StatusAssetSettings.qml | 1 + .../community/MembershipRequestsPopup.qml | 42 ++++++--------- .../mainui/activitycenter/controls/Badge.qml | 3 +- .../panels/ActivityCenterPopupTopBarPanel.qml | 2 +- .../panels/ContactRequestCta.qml | 4 +- .../activitycenter/panels/MembershipCta.qml | 53 ++++++++----------- .../views/ActivityNotificationBase.qml | 6 +-- ...ctivityNotificationCommunityInvitation.qml | 2 +- ...NotificationCommunityMembershipRequest.qml | 6 +-- 13 files changed, 67 insertions(+), 80 deletions(-) diff --git a/src/app/modules/main/activity_center/item.nim b/src/app/modules/main/activity_center/item.nim index aacb7c4162..4abcbe9df5 100644 --- a/src/app/modules/main/activity_center/item.nim +++ b/src/app/modules/main/activity_center/item.nim @@ -1,15 +1,16 @@ import strformat, stint import ../../shared_models/message_item_qobject +import ../../../../app_service/service/activity_center/dto/notification type Item* = ref object id: string # ID is the id of the chat, for public chats it is the name e.g. status, for one-to-one is the hex encoded public key and for group chats is a random uuid appended with the hex encoded pk of the creator of the chat chatId: string communityId: string - membershipStatus: int + membershipStatus: ActivityCenterMembershipStatus sectionId: string name: string author: string - notificationType: int + notificationType: ActivityCenterNotificationType timestamp: int64 read: bool dismissed: bool @@ -21,11 +22,11 @@ proc initItem*( id: string, chatId: string, communityId: string, - membershipStatus: int, + membershipStatus: ActivityCenterMembershipStatus, sectionId: string, name: string, author: string, - notificationType: int, + notificationType: ActivityCenterNotificationType, timestamp: int64, read: bool, dismissed: bool, @@ -55,10 +56,10 @@ proc `$`*(self: Item): string = name: {$self.name}, chatId: {$self.chatId}, communityId: {$self.communityId}, - membershipStatus: {$self.membershipStatus}, + membershipStatus: {$self.membershipStatus.int}, sectionId: {$self.sectionId}, author: {$self.author}, - notificationType: {$self.notificationType}, + notificationType: {$self.notificationType.int}, timestamp: {$self.timestamp}, read: {$self.read}, dismissed: {$self.dismissed}, @@ -82,13 +83,13 @@ proc chatId*(self: Item): string = proc communityId*(self: Item): string = return self.communityId -proc membershipStatus*(self: Item): int = +proc membershipStatus*(self: Item): ActivityCenterMembershipStatus = return self.membershipStatus proc sectionId*(self: Item): string = return self.sectionId -proc notificationType*(self: Item): int = +proc notificationType*(self: Item): ActivityCenterNotificationType = return self.notificationType proc timestamp*(self: Item): int64 = diff --git a/src/app/modules/main/activity_center/module.nim b/src/app/modules/main/activity_center/module.nim index fc9748fb4c..f923e45f3b 100644 --- a/src/app/modules/main/activity_center/module.nim +++ b/src/app/modules/main/activity_center/module.nim @@ -128,11 +128,11 @@ method convertToItems*( n.id, n.chatId, n.communityId, - n.membershipStatus.int, + n.membershipStatus, sectionId, n.name, n.author, - n.notificationType.int, + n.notificationType, n.timestamp, n.read, n.dismissed, diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 9cc22f0222..77c7f25aac 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -624,6 +624,7 @@ QtObject: proc requestToJoinCommunity*(self: Service, communityId: string, ensName: string) = try: let response = status_go.requestToJoinCommunity(communityId, ensName) + self.activityCenterService.parseACNotificationResponse(response) if not self.processRequestsToJoinCommunity(response.result): error "error: ", procName="requestToJoinCommunity", errDesription = "no 'requestsToJoinCommunity' key in response" @@ -668,6 +669,7 @@ QtObject: proc leaveCommunity*(self: Service, communityId: string) = try: let response = status_go.leaveCommunity(communityId) + self.activityCenterService.parseACNotificationResponse(response) if response.error != nil: let error = Json.decode($response.error, RpcError) diff --git a/ui/StatusQ/src/StatusQ/Controls/StatusRoundButton.qml b/ui/StatusQ/src/StatusQ/Controls/StatusRoundButton.qml index f167cd61da..e8edb69e15 100644 --- a/ui/StatusQ/src/StatusQ/Controls/StatusRoundButton.qml +++ b/ui/StatusQ/src/StatusQ/Controls/StatusRoundButton.qml @@ -8,11 +8,12 @@ Rectangle { id: statusRoundButton property StatusAssetSettings icon: StatusAssetSettings { + id: icon width: 23 height: 23 rotation: 0 - property color hoverColor: { + hoverColor: { switch(statusRoundButton.type) { case StatusRoundButton.Type.Primary: return Theme.palette.primaryColor1; @@ -32,7 +33,7 @@ Rectangle { case StatusRoundButton.Type.Tertiary: return Theme.palette.baseColor1; } - } + } disabledColor: { switch(statusRoundButton.type) { diff --git a/ui/StatusQ/src/StatusQ/Core/StatusAssetSettings.qml b/ui/StatusQ/src/StatusQ/Core/StatusAssetSettings.qml index 08cbb296eb..bdd7ba6526 100644 --- a/ui/StatusQ/src/StatusQ/Core/StatusAssetSettings.qml +++ b/ui/StatusQ/src/StatusQ/Core/StatusAssetSettings.qml @@ -10,6 +10,7 @@ QtObject { property real width property real height property color color + property color hoverColor property color disabledColor property int rotation property bool isLetterIdenticon diff --git a/ui/app/AppLayouts/Chat/popups/community/MembershipRequestsPopup.qml b/ui/app/AppLayouts/Chat/popups/community/MembershipRequestsPopup.qml index 4b9fee814c..54b2e7a952 100644 --- a/ui/app/AppLayouts/Chat/popups/community/MembershipRequestsPopup.qml +++ b/ui/app/AppLayouts/Chat/popups/community/MembershipRequestsPopup.qml @@ -65,33 +65,23 @@ StatusModal { title: displayName components: [ - StatusRoundIcon { - asset.name: "thumbs-up" - asset.color: Theme.palette.white - asset.bgWidth: 28 - asset.bgHeight: 28 - asset.bgColor: Theme.palette.successColor1 - MouseArea { - id: thumbsUpSensor - hoverEnabled: true - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: communitySectionModule.acceptRequestToJoinCommunity(id, popup.communityData.id) - } + StatusRoundButton { + icon.name: "thumbs-up" + icon.color: Style.current.white + icon.hoverColor: Style.current.white + implicitWidth: 28 + implicitHeight: 28 + color: Theme.palette.successColor1 + onClicked: popup.store.acceptRequestToJoinCommunity(id, popup.communityData.id) }, - StatusRoundIcon { - asset.name: "thumbs-down" - asset.color: Theme.palette.white - asset.bgWidth: 28 - asset.bgHeight: 28 - asset.bgColor: Theme.palette.dangerColor1 - MouseArea { - id: thumbsDownSensor - hoverEnabled: true - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: communitySectionModule.declineRequestToJoinCommunity(id, popup.communityData.id) - } + StatusRoundButton { + icon.name: "thumbs-down" + icon.color: Style.current.white + icon.hoverColor: Style.current.white + implicitWidth: 28 + implicitHeight: 28 + color: Theme.palette.dangerColor1 + onClicked: popup.store.declineRequestToJoinCommunity(id, popup.communityData.id) } ] } diff --git a/ui/app/mainui/activitycenter/controls/Badge.qml b/ui/app/mainui/activitycenter/controls/Badge.qml index c74d8d1c71..e9fa9d1f6b 100644 --- a/ui/app/mainui/activitycenter/controls/Badge.qml +++ b/ui/app/mainui/activitycenter/controls/Badge.qml @@ -9,11 +9,10 @@ Rectangle { id: root z: 100 // NOTE: workaround for message overlay - implicitWidth: childrenRect.width + Style.current.smallPadding + implicitWidth: childrenRect.width + Style.current.smallPadding * 2 implicitHeight: visible ? 24 : 0 radius: height / 2 border.width: 1 border.color: Style.current.borderSecondary color: Style.current.transparent } - diff --git a/ui/app/mainui/activitycenter/panels/ActivityCenterPopupTopBarPanel.qml b/ui/app/mainui/activitycenter/panels/ActivityCenterPopupTopBarPanel.qml index 72527e5efd..da71dd4822 100644 --- a/ui/app/mainui/activitycenter/panels/ActivityCenterPopupTopBarPanel.qml +++ b/ui/app/mainui/activitycenter/panels/ActivityCenterPopupTopBarPanel.qml @@ -44,7 +44,7 @@ Item { id: listView // NOTE: some entries are hidden until implimentation model: [ { text: qsTr("All"), category: ActivityCenterPopup.ActivityCategory.All, visible: true, enabled: true }, - { text: qsTr("Admin"), category: ActivityCenterPopup.ActivityCategory.Admin, visible: true, enabled: root.hasAdmin }, + { text: qsTr("Admin"), category: ActivityCenterPopup.ActivityCategory.Admin, visible: root.hasAdmin, enabled: root.hasAdmin }, { text: qsTr("Mentions"), category: ActivityCenterPopup.ActivityCategory.Mentions, visible: true, enabled: root.hasMentions }, { text: qsTr("Replies"), category: ActivityCenterPopup.ActivityCategory.Replies, visible: true, enabled: root.hasReplies }, { text: qsTr("Contact requests"), category: ActivityCenterPopup.ActivityCategory.ContactRequests, visible: true, enabled: root.hasContactRequests }, diff --git a/ui/app/mainui/activitycenter/panels/ContactRequestCta.qml b/ui/app/mainui/activitycenter/panels/ContactRequestCta.qml index 9c8e46a0e7..11be860971 100644 --- a/ui/app/mainui/activitycenter/panels/ContactRequestCta.qml +++ b/ui/app/mainui/activitycenter/panels/ContactRequestCta.qml @@ -19,8 +19,8 @@ Item { signal blockClicked() signal profileClicked() - width: Math.max(textItem.width, buttons.width) - height: Math.max(textItem.height, buttons.height) + implicitWidth: Math.max(textItem.width, buttons.width) + implicitHeight: Math.max(textItem.height, buttons.height) StatusBaseText { id: textItem diff --git a/ui/app/mainui/activitycenter/panels/MembershipCta.qml b/ui/app/mainui/activitycenter/panels/MembershipCta.qml index 98b2b19b0c..9f223a9ffb 100644 --- a/ui/app/mainui/activitycenter/panels/MembershipCta.qml +++ b/ui/app/mainui/activitycenter/panels/MembershipCta.qml @@ -2,6 +2,7 @@ import QtQuick 2.14 import StatusQ.Core 0.1 import StatusQ.Core.Theme 0.1 +import StatusQ.Controls 0.1 import StatusQ.Components 0.1 import utils 1.0 @@ -17,8 +18,8 @@ Item { signal acceptRequestToJoinCommunity() signal declineRequestToJoinCommunity() - width: Math.max(textItem.width, buttons.width) - height: Math.max(textItem.height, buttons.height) + implicitWidth: Math.max(textItem.width, buttons.width) + implicitHeight: Math.max(textItem.height, buttons.height) StatusBaseText { id: textItem @@ -28,7 +29,8 @@ Item { text: { if (root.accepted) { return qsTr("Accepted") - } else if (root.declined) { + } + if (root.declined) { return qsTr("Declined") } return "" @@ -36,7 +38,8 @@ Item { color: { if (root.accepted) { return Theme.palette.successColor1 - } else if (root.declined) { + } + if (root.declined) { return Theme.palette.dangerColor1 } return Theme.palette.directColor1 @@ -49,34 +52,24 @@ Item { visible: pending spacing: Style.current.padding - StatusRoundIcon { - asset.name: "thumbs-up" - asset.color: Theme.palette.white - asset.bgWidth: 28 - asset.bgHeight: 28 - asset.bgColor: Theme.palette.successColor1 - MouseArea { - id: thumbsUpSensor - hoverEnabled: true - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: root.acceptRequestToJoinCommunity() - } + StatusRoundButton { + icon.name: "thumbs-up" + icon.color: Style.current.white + icon.hoverColor: Style.current.white + implicitWidth: 28 + implicitHeight: 28 + color: Theme.palette.successColor1 + onClicked: root.acceptRequestToJoinCommunity() } - StatusRoundIcon { - asset.name: "thumbs-down" - asset.color: Theme.palette.white - asset.bgWidth: 28 - asset.bgHeight: 28 - asset.bgColor: Theme.palette.dangerColor1 - MouseArea { - id: thumbsDownSensor - hoverEnabled: true - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: root.declineRequestToJoinCommunity() - } + StatusRoundButton { + icon.name: "thumbs-down" + icon.color: Style.current.white + icon.hoverColor: Style.current.white + implicitWidth: 28 + implicitHeight: 28 + color: Theme.palette.dangerColor1 + onClicked: root.declineRequestToJoinCommunity() } } } \ No newline at end of file diff --git a/ui/app/mainui/activitycenter/views/ActivityNotificationBase.qml b/ui/app/mainui/activitycenter/views/ActivityNotificationBase.qml index 4992414d46..b58e99705c 100644 --- a/ui/app/mainui/activitycenter/views/ActivityNotificationBase.qml +++ b/ui/app/mainui/activitycenter/views/ActivityNotificationBase.qml @@ -19,9 +19,9 @@ Item { property alias ctaComponent: ctaLoader.sourceComponent property alias previousNotificationIndex: dateGroupLabel.previousMessageIndex - height: Math.max(60, bodyLoader.height + - (dateGroupLabel.visible ? dateGroupLabel.height : 0) + - (badgeLoader.item ? badgeLoader.height : 0)) + implicitHeight: Math.max(60, bodyLoader.height + + (dateGroupLabel.visible ? dateGroupLabel.height : 0) + + (badgeLoader.item ? badgeLoader.height : 0)) StatusDateGroupLabel { id: dateGroupLabel diff --git a/ui/app/mainui/activitycenter/views/ActivityNotificationCommunityInvitation.qml b/ui/app/mainui/activitycenter/views/ActivityNotificationCommunityInvitation.qml index 1fc9b8ab9b..70b82a4fcd 100644 --- a/ui/app/mainui/activitycenter/views/ActivityNotificationCommunityInvitation.qml +++ b/ui/app/mainui/activitycenter/views/ActivityNotificationCommunityInvitation.qml @@ -17,7 +17,7 @@ ActivityNotificationMessage { badgeComponent: CommunityBadge { id: communityBadge - property var community: root.store.getCommunityDetailsAsJson(notification.message.communityId) + readonly property var community: root.store.getCommunityDetailsAsJson(notification.message.communityId) communityName: community.name communityImage: community.image diff --git a/ui/app/mainui/activitycenter/views/ActivityNotificationCommunityMembershipRequest.qml b/ui/app/mainui/activitycenter/views/ActivityNotificationCommunityMembershipRequest.qml index 5fe1692e20..26f5a5353f 100644 --- a/ui/app/mainui/activitycenter/views/ActivityNotificationCommunityMembershipRequest.qml +++ b/ui/app/mainui/activitycenter/views/ActivityNotificationCommunityMembershipRequest.qml @@ -21,7 +21,7 @@ ActivityNotificationBase { signal activityCenterClose() bodyComponent: MessageView { - readonly property var contactDetails: Utils.getContactDetailsAsJson(senderId) + readonly property var contactDetails: Utils.getContactDetailsAsJson(notification.author) rootStore: root.store messageStore: root.store.messageStore @@ -30,11 +30,11 @@ ActivityNotificationBase { messageTimestamp: notification.timestamp senderId: notification.author senderIcon: contactDetails.displayIcon - senderDisplayName: contactDetails.name + senderDisplayName: contactDetails.displayName + senderOptionalName: contactDetails.localNickname messageContextMenu: root.messageContextMenu activityCenterMessage: true activityCenterMessageRead: false - scrollToBottom: null onImageClicked: Global.openImagePopup(image, root.messageContextMenu) messageClickHandler: (sender, point,