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 3, 2025
1 parent 9809a47 commit 7ccf7d2
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
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 pendingReceivedRequestContactsModel
property var pendingSentRequestContactsModel
property var dismissedReceivedRequestContactsModel

required property bool isCentralizedMetricsEnabled

Expand Down Expand Up @@ -245,6 +246,7 @@ StatusSectionLayout {
mutualContactsModel: root.mutualContactsModel
blockedContactsModel: root.blockedContactsModel
pendingReceivedRequestContactsModel: root.pendingReceivedRequestContactsModel
dismissedReceivedRequestContactsModel: root.dismissedReceivedRequestContactsModel
pendingSentRequestContactsModel: root.pendingSentRequestContactsModel
}
}
Expand Down
28 changes: 24 additions & 4 deletions ui/app/AppLayouts/Profile/views/ContactsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SettingsContentBase {
property var blockedContactsModel
property var pendingReceivedRequestContactsModel
property var pendingSentRequestContactsModel
property var dismissedReceivedRequestContactsModel

property alias searchStr: searchBox.text
property bool isPending: false
Expand Down Expand Up @@ -113,13 +114,11 @@ SettingsContentBase {
anchors.topMargin: Theme.padding

StatusTabButton {
id: contactsBtn
leftPadding: Theme.padding
width: implicitWidth
text: qsTr("Contacts")
}
StatusTabButton {
id: pendingRequestsBtn
objectName: "ContactsView_PendingRequest_Button"
width: implicitWidth
enabled: !root.pendingReceivedRequestContactsModel.ModelCount.empty ||
Expand All @@ -128,7 +127,12 @@ SettingsContentBase {
badge.value: root.pendingReceivedRequestContactsModel.ModelCount.count
}
StatusTabButton {
id: blockedBtn
objectName: "ContactsView_DismissedRequest_Button"
width: implicitWidth
enabled: !root.dismissedReceivedRequestContactsModel.ModelCount.empty
text: qsTr("Dismissed Requests")
}
StatusTabButton {
objectName: "ContactsView_Blocked_Button"
width: implicitWidth
enabled: !root.blockedContactsModel.ModelCount.empty
Expand Down Expand Up @@ -251,6 +255,22 @@ SettingsContentBase {
}
}

// DISMISSED REQUESTS
ContactsListPanel {
Layout.fillWidth: true
searchString: searchBox.text
onOpenContactContextMenu: root.openContextMenu(contactsModel, publicKey)
contactsModel: root.dismissedReceivedRequestContactsModel
panelUsage: Constants.contactsPanelUsage.rejectedReceivedContactRequest
visible: (stackLayout.currentIndex === 2)
onVisibleChanged: {
if (visible) {
stackLayout.height = height;
}
}
onRejectionRemoved: root.contactsStore.acceptContactRequest(publicKey, "")
}

// BLOCKED
ContactsListPanel {
id: blockedContacts
Expand All @@ -260,7 +280,7 @@ SettingsContentBase {
onOpenContactContextMenu: root.openContextMenu(contactsModel, publicKey)
contactsModel: root.blockedContactsModel
panelUsage: Constants.contactsPanelUsage.blockedContacts
visible: (stackLayout.currentIndex === 2)
visible: (stackLayout.currentIndex === 3)
onVisibleChanged: {
if (visible) {
stackLayout.height = height;
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 @@ -1733,6 +1733,7 @@ Item {
blockedContactsModel: contactsModelAdaptor.blockedContacts
pendingReceivedRequestContactsModel: contactsModelAdaptor.pendingReceivedRequestContacts
pendingSentRequestContactsModel: contactsModelAdaptor.pendingSentRequestContacts
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 @@ -75,4 +75,19 @@ QObject {
value: Constants.ContactRequestState.Sent
}
}

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

filters: [
ValueFilter {
roleName: "contactRequest"
value: Constants.ContactRequestState.Dismissed
},
ValueFilter {
roleName: "isBlocked"
value: false
}
]
}
}

0 comments on commit 7ccf7d2

Please sign in to comment.