Skip to content

Commit

Permalink
feat: show activity center notification if user must reveal addressed…
Browse files Browse the repository at this point in the history
… to join/rejoin the communit
  • Loading branch information
mprakhov committed Nov 23, 2023
1 parent fdc36b7 commit 2e2c284
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/app_service/service/activity_center/dto/notification.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type ActivityCenterNotificationType* {.pure.}= enum
OwnershipLost = 15
SetSignerFailed = 16
SetSignerDeclined = 17
ShareAccounts = 18

type ActivityCenterGroup* {.pure.}= enum
All = 0,
Expand Down Expand Up @@ -162,7 +163,8 @@ proc activityCenterNotificationTypesByGroup*(group: ActivityCenterGroup) : seq[i
ActivityCenterNotificationType.OwnershipReceived.int,
ActivityCenterNotificationType.SetSignerFailed.int,
ActivityCenterNotificationType.SetSignerDeclined.int,
ActivityCenterNotificationType.OwnershipLost.int
ActivityCenterNotificationType.OwnershipLost.int,
ActivityCenterNotificationType.ShareAccounts.int
]
of ActivityCenterGroup.Mentions:
return @[ActivityCenterNotificationType.Mention.int]
Expand Down
13 changes: 13 additions & 0 deletions ui/app/mainui/Popups.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ QtObject {
Global.openCommunityProfilePopupRequested.connect(openCommunityProfilePopup)
Global.createCommunityPopupRequested.connect(openCreateCommunityPopup)
Global.importCommunityPopupRequested.connect(openImportCommunityPopup)
Global.communityShareAddressesPopupRequested.connect(openCommunityShareAddressesPopup)
Global.communityIntroPopupRequested.connect(openCommunityIntroPopup)
Global.removeContactRequested.connect(openRemoveContactConfirmationPopup)
Global.openPopupRequested.connect(openPopup)
Expand Down Expand Up @@ -241,6 +242,18 @@ QtObject {
})
}

function openCommunityShareAddressesPopup(communityId, name, imageSrc) {
openPopup(communityIntroDialogPopup,
{communityId: communityId,
stackTitle: qsTr("Share addresses with %1's owner").arg(name),
name: name,
introMessage: qsTr("Share addresses to rejoin %1").arg(name),
imageSrc: imageSrc,
accessType: Constants.communityChatOnRequestAccess,
isInvitationPending: false
})
}

function openEditSharedAddressesPopup(communityId) {
openPopup(editSharedAddressesPopupComponent, {communityId: communityId, isEditMode: true})
}
Expand Down
25 changes: 25 additions & 0 deletions ui/app/mainui/activitycenter/popups/ActivityCenterPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ Popup {
case ActivityCenterStore.ActivityCenterNotificationType.OwnershipFailed:
case ActivityCenterStore.ActivityCenterNotificationType.OwnershipDeclined:
return ownerTokenReceivedNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.ShareAccounts:
return shareAccountsNotificationComponent
default:
return null
}
Expand Down Expand Up @@ -275,4 +277,27 @@ Popup {
onNavigateToCommunityClicked: root.store.setActiveCommunity(notification.communityId)
}
}

Component {
id: shareAccountsNotificationComponent

ActivityNotificationCommunityShareAddresses {

readonly property var community : notification ? root.store.getCommunityDetailsAsJson(notification.communityId) : null

communityName: community ? community.name : ""
communityColor: community ? community.color : "black"
communityImage: community ? community.image : ""

filteredIndex: parent.filteredIndex
notification: parent.notification
store: root.store
activityCenterStore: root.activityCenterStore
onCloseActivityCenter: root.close()

onOpenShareAccountsClicked: {
Global.communityShareAddressesPopupRequested(notification.communityId, communityName, communityImage)
}
}
}
}
3 changes: 2 additions & 1 deletion ui/app/mainui/activitycenter/stores/ActivityCenterStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ QtObject {
OwnershipReceived = 14,
OwnershipLost = 15,
OwnershipFailed = 16,
OwnershipDeclined = 17
OwnershipDeclined = 17,
ShareAccounts = 18
}

enum ActivityCenterReadType {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import QtQuick 2.14
import QtQuick.Layouts 1.14

import StatusQ.Controls 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1

import shared 1.0
import shared.panels 1.0
import utils 1.0

import "../panels"
import "../popups"
import "../stores"

ActivityNotificationBase {
id: root

required property string communityName
required property string communityColor
required property string communityImage

signal openCommunityClicked
signal openShareAccountsClicked

bodyComponent: RowLayout {
spacing: 8

StatusSmartIdenticon {
name: root.communityName
Layout.preferredWidth: 40
Layout.preferredHeight: 40
Layout.alignment: Qt.AlignTop
Layout.leftMargin: Style.current.padding
Layout.topMargin: 2

asset {
width: 24
height: width
name: root.communityImage
color: root.communityColor
bgWidth: 40
bgHeight: 40
}
}

ColumnLayout {
spacing: 2
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true

StatusMessageHeader {
displayNameLabel.text: qsTr("%1 requires you to share your Accounts").arg(root.communityName)
timestamp: root.notification.timestamp
}

RowLayout {
spacing: Style.current.padding

StatusBaseText {
Layout.fillWidth: true
text: qsTr("To continue to be a member of %1, you need to share your accounts").arg(root.communityName)
font.italic: true
wrapMode: Text.WordWrap
color: Theme.palette.baseColor1
}

StatusFlatButton {
size: StatusBaseButton.Size.Small
text: qsTr("Share")
onClicked: {
root.openShareAccountsClicked()
}
}
}
}
}

ctaComponent: undefined
}
1 change: 1 addition & 0 deletions ui/app/mainui/activitycenter/views/qmldir
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ActivityNotificationCommunityMembershipRequest 1.0 ActivityNotificationCommunityMembershipRequest.qml
ActivityNotificationTransferOwnership 1.0 ActivityNotificationTransferOwnership.qml
ActivityNotificationCommunityShareAddresses 1.0 ActivityNotificationCommunityShareAddresses.qml
1 change: 1 addition & 0 deletions ui/imports/utils/Global.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ QtObject {
signal importCommunityPopupRequested()
signal communityIntroPopupRequested(string communityId, string name, string introMessage,
string imageSrc, int accessType, bool isInvitationPending)
signal communityShareAddressesPopupRequested(string communityId, string name, string imageSrc)
signal leaveCommunityRequested(string community, string communityId, string outroMessage)
signal openEditSharedAddressesFlow(string communityId)

Expand Down

0 comments on commit 2e2c284

Please sign in to comment.