Skip to content

Commit

Permalink
feat(contacts): add a tab for dismissed contacts and a button to undo
Browse files Browse the repository at this point in the history
Fixes #16844

Adds a tab in the Messaging>Contacts page that shows the dismissed contact requests.
it has a button to undo the rejection. That is simply a call to accept the old contact request, which then makes the two users mutual contacts
  • Loading branch information
jrainville committed Jan 14, 2025
1 parent 7babefd commit 1295d9a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions storybook/pages/ContactsViewPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Item {
mutualContactsModel: adaptor.mutualContacts
blockedContactsModel: adaptor.blockedContacts
pendingContactsModel: adaptor.pendingContacts
dismissedReceivedRequestContactsModel: adaptor.dismissedReceivedRequestContactsModel
pendingReceivedContactsCount: adaptor.pendingReceivedRequestContacts.count
}

Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Profile/ProfileLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ StatusSectionLayout {
property var blockedContactsModel
property var pendingContactsModel
property int pendingReceivedContactsCount
property var dismissedReceivedRequestContactsModel

required property bool isCentralizedMetricsEnabled

Expand Down Expand Up @@ -246,6 +247,7 @@ StatusSectionLayout {
blockedContactsModel: root.blockedContactsModel
pendingContactsModel: root.pendingContactsModel
pendingReceivedContactsCount: root.pendingReceivedContactsCount
dismissedReceivedRequestContactsModel: root.dismissedReceivedRequestContactsModel
}
}

Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Profile/panels/ContactPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ ContactListItemDelegate {
property bool showSendMessageButton: false
property bool showRejectContactRequestButton: false
property bool showAcceptContactRequestButton: false
property bool showRemoveRejectionButton: false
property string contactText: ""

signal contextMenuRequested
signal sendMessageRequested
signal acceptContactRequested
signal rejectRequestRequested
signal removeRejectionRequested

icon.width: 40
icon.height: 40
Expand Down
3 changes: 3 additions & 0 deletions ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ StatusListView {
signal sendMessageRequested(string publicKey)
signal acceptContactRequested(string publicKey)
signal rejectContactRequested(string publicKey)
signal rejectionRemoved(string publicKey)

objectName: "ContactListPanel_ListView"

Expand All @@ -32,6 +33,7 @@ StatusListView {
showRejectContactRequestButton:
model.contactRequest === Constants.ContactRequestState.Received
showAcceptContactRequestButton: showRejectContactRequestButton
showRemoveRejectionButton: model.contactRequest === Constants.ContactRequestState.Dismissed

contactText: model.contactRequest === Constants.ContactRequestState.Sent
? qsTr("Contact Request Sent") : ""
Expand All @@ -41,5 +43,6 @@ StatusListView {
onSendMessageRequested: root.sendMessageRequested(model.pubKey)
onAcceptContactRequested: root.acceptContactRequested(model.pubKey)
onRejectRequestRequested: root.rejectContactRequested(model.pubKey)
onRemoveRejectionRequested: root.rejectionRemoved(model.pubKey)
}
}
24 changes: 24 additions & 0 deletions ui/app/AppLayouts/Profile/views/ContactsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SettingsContentBase {
required property var blockedContactsModel
required property var pendingContactsModel
required property int pendingReceivedContactsCount
required property var dismissedReceivedRequestContactsModel

property alias searchStr: searchBox.text

Expand Down Expand Up @@ -87,6 +88,13 @@ SettingsContentBase {
text: qsTr("Pending Requests")
badge.value: root.pendingReceivedContactsCount
}
StatusTabButton {
objectName: "ContactsView_DismissedRequest_Button"

width: implicitWidth
enabled: !root.dismissedReceivedRequestContactsModel.ModelCount.empty
text: qsTr("Dismissed Requests")
}
StatusTabButton {
objectName: "ContactsView_Blocked_Button"

Expand Down Expand Up @@ -175,6 +183,21 @@ SettingsContentBase {
ViewSection.CurrentLabelAtStart
}

ContactsList {
model: SortFilterProxyModel {
sourceModel: root.dismissedReceivedRequestContactsModel

filters: UserSearchFilter {
searchString: searchBox.text
}

sorters: StringSorter {
roleName: "preferredDisplayName"
caseSensitivity: Qt.CaseInsensitive
}
}
}

ContactsList {
model: SortFilterProxyModel {
sourceModel: root.blockedContactsModel
Expand All @@ -198,6 +221,7 @@ SettingsContentBase {
onSendMessageRequested: root.contactsStore.joinPrivateChat(publicKey)
onAcceptContactRequested: root.contactsStore.acceptContactRequest(publicKey, "")
onRejectContactRequested: root.contactsStore.dismissContactRequest(publicKey, "")
onRejectionRemoved: root.contactsStore.acceptContactRequest(publicKey, "")
}

component SectionComponent: Rectangle {
Expand Down
1 change: 1 addition & 0 deletions ui/app/mainui/AppMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,7 @@ Item {
blockedContactsModel: contactsModelAdaptor.blockedContacts
pendingContactsModel: contactsModelAdaptor.pendingContacts
pendingReceivedContactsCount: contactsModelAdaptor.pendingReceivedRequestContacts.count
dismissedReceivedRequestContactsModel: contactsModelAdaptor.dimissedReceivedRequestContacts

Binding on settingsSubsection {
value: profileLoader.settingsSubsection
Expand Down
15 changes: 15 additions & 0 deletions ui/app/mainui/adaptors/ContactsModelAdaptor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,19 @@ QObject {
}
]
}

readonly property var dimissedReceivedRequestContacts: SortFilterProxyModel {
sourceModel: root.allContacts ?? null

filters: [
ValueFilter {
roleName: "contactRequest"
value: Constants.ContactRequestState.Dismissed
},
ValueFilter {
roleName: "isBlocked"
value: false
}
]
}
}
1 change: 1 addition & 0 deletions ui/imports/utils/Constants.qml
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ QtObject {
readonly property int mutualContacts: 0
readonly property int pendingContacts: 1
readonly property int blockedContacts: 2
readonly property int rejectedReceivedContactRequest: 3
}

readonly property QtObject keypair: QtObject {
Expand Down

0 comments on commit 1295d9a

Please sign in to comment.