Skip to content

Commit

Permalink
feat(ActivityCenter): Review fixed for community membership AС notifi…
Browse files Browse the repository at this point in the history
…cations
  • Loading branch information
MishkaRogachev committed Oct 25, 2022
1 parent 00e541a commit db26abd
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 80 deletions.
17 changes: 9 additions & 8 deletions src/app/modules/main/activity_center/item.nim
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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},
Expand All @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/main/activity_center/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/app_service/service/community/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions ui/StatusQ/src/StatusQ/Controls/StatusRoundButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +33,7 @@ Rectangle {
case StatusRoundButton.Type.Tertiary:
return Theme.palette.baseColor1;
}
}
}

disabledColor: {
switch(statusRoundButton.type) {
Expand Down
1 change: 1 addition & 0 deletions ui/StatusQ/src/StatusQ/Core/StatusAssetSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 16 additions & 26 deletions ui/app/AppLayouts/Chat/popups/community/MembershipRequestsPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
]
}
Expand Down
3 changes: 1 addition & 2 deletions ui/app/mainui/activitycenter/controls/Badge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
4 changes: 2 additions & 2 deletions ui/app/mainui/activitycenter/panels/ContactRequestCta.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 23 additions & 30 deletions ui/app/mainui/activitycenter/panels/MembershipCta.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -28,15 +29,17 @@ Item {
text: {
if (root.accepted) {
return qsTr("Accepted")
} else if (root.declined) {
}
if (root.declined) {
return qsTr("Declined")
}
return ""
}
color: {
if (root.accepted) {
return Theme.palette.successColor1
} else if (root.declined) {
}
if (root.declined) {
return Theme.palette.dangerColor1
}
return Theme.palette.directColor1
Expand All @@ -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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,7 +30,8 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion vendor/status-go
Submodule status-go updated 49 files
+1 −2 .travis.yml
+1 −1 VERSION
+0 −1 _assets/ci/Jenkinsfile.ios
+1 −1 abi-spec/core_test.go
+255 −0 abi-spec/utf8.go
+170 −0 abi-spec/utils.go
+72 −0 abi-spec/utils_test.go
+1 −1 cmd/node-canary/main.go
+3 −3 cmd/ping-community/main.go
+19 −3 cmd/populate-db/main.go
+3 −3 cmd/statusd/main.go
+22 −7 contracts/contracts.go
+0 −2 contracts/ethscan/address.go
+0 −1 contracts/resolver/address.go
+0 −1 contracts/snt/address.go
+0 −3 contracts/stickers/address.go
+1 −1 go.mod
+46 −0 mobile/status.go
+1 −1 node/geth_node_test.go
+2 −8 params/config.go
+3 −3 params/config_test.go
+0 −14 params/defaults.go
+44 −6 protocol/common/message_sender.go
+29 −0 protocol/common/raw_messages_persistence.go
+127 −38 protocol/communities/manager.go
+154 −12 protocol/communities/manager_test.go
+1 −1 protocol/communities/persistence.go
+8 −3 protocol/communities_messenger_test.go
+2 −2 protocol/encryption/encryption_test.go
+16 −6 protocol/encryption/encryptor.go
+29 −0 protocol/encryption/persistence.go
+51 −11 protocol/encryption/protocol.go
+133 −43 protocol/encryption/protocol_message.pb.go
+9 −0 protocol/encryption/protocol_message.proto
+1 −1 protocol/messenger.go
+27 −16 protocol/messenger_communities.go
+14 −12 protocol/messenger_handler.go
+25 −1 protocol/migrations/migrations.go
+15 −0 protocol/migrations/sqlite/1665484435_add_encrypted_messages.up.sql
+39 −0 protocol/persistence_test.go
+12 −0 protocol/v1/status_message.go
+0 −26 rpc/network/network_test.go
+9 −0 services/ens/api.go
+10 −0 services/ens/api_test.go
+1 −1 services/wallet/token.go
+8 −2 services/wallet/transfer/commands.go
+2 −6 services/wallet/transfer/iterative.go
+1 −1 t/doc.go
+0 −14 t/utils/utils.go

0 comments on commit db26abd

Please sign in to comment.