fix(messenger_contacts): Add toast notification when removing a contact

Fixes #10497
This commit is contained in:
Shinnok 2023-10-03 13:37:20 +03:00 committed by GitHub
parent 6b0e541bf1
commit d9e6fbe0d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 9 deletions

View File

@ -10,6 +10,7 @@ type
TestNotification,
NewContactRequest,
AcceptedContactRequest,
ContactRemoved,
JoinCommunityRequest,
MyRequestToJoinCommunityAccepted,
MyRequestToJoinCommunityRejected,

View File

@ -75,6 +75,10 @@ QtObject:
self, "onShowMessageNotification(QString, QString, QString, bool, bool, QString, bool, QString, int, bool, bool)", 2)
signalConnect(singletonInstance.globalEvents, "showNewContactRequestNotification(QString, QString, QString)",
self, "onShowNewContactRequestNotification(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "showAcceptedContactRequest(QString, QString, QString)",
self, "onShowAcceptedContactRequest(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "showContactRemoved(QString, QString, QString)",
self, "onShowContactRemoved(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "newCommunityMembershipRequestNotification(QString, QString, QString)",
self, "onNewCommunityMembershipRequestNotification(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "myRequestToJoinCommunityAcccepted(QString, QString, QString)",
@ -83,8 +87,6 @@ QtObject:
self, "onMyRequestToJoinCommunityRejected(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "meMentionedIconBadgeNotification(int)",
self, "onMeMentionedIconBadgeNotification(int)", 2)
signalConnect(singletonInstance.globalEvents, "showAcceptedContactRequest(QString, QString, QString)",
self, "onShowAcceptedContactRequest(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "showCommunityTokenPermissionCreatedNotification(QString, QString, QString)", self, "onShowCommunityTokenPermissionCreatedNotification(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "showCommunityTokenPermissionUpdatedNotification(QString, QString, QString)", self, "onShowCommunityTokenPermissionUpdatedNotification(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "showCommunityTokenPermissionDeletedNotification(QString, QString, QString)", self, "onShowCommunityTokenPermissionDeletedNotification(QString, QString, QString)", 2)
@ -180,6 +182,11 @@ QtObject:
let details = NotificationDetails(notificationType: NotificationType.AcceptedContactRequest, sectionId: sectionId)
self.processNotification(title, message, details)
proc onShowContactRemoved*(self: NotificationsManager, title: string, message: string,
sectionId: string) {.slot.} =
let details = NotificationDetails(notificationType: NotificationType.ContactRemoved, sectionId: sectionId)
self.processNotification(title, message, details)
proc onNewCommunityMembershipRequestNotification*(self: NotificationsManager, title: string, message: string,
sectionId: string) {.slot.} =
let details = NotificationDetails(notificationType: NotificationType.JoinCommunityRequest, sectionId: sectionId)
@ -217,6 +224,7 @@ QtObject:
details.notificationType == NotificationType.NewMessageWithPersonalMention or
details.notificationType == NotificationType.NewMessageWithGlobalMention or
details.notificationType == NotificationType.NewContactRequest or
details.notificationType == NotificationType.ContactRemoved or
details.notificationType == NotificationType.IdentityVerificationRequest):
if(notificationWay == VALUE_NOTIF_DELIVER_QUIETLY):
@ -335,7 +343,7 @@ QtObject:
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingGroupChats())
return
# In all other cases (TestNotification, AcceptedContactRequest, JoinCommunityRequest, MyRequestToJoinCommunityAccepted,
# In all other cases (TestNotification, AcceptedContactRequest, ContactRemoved, JoinCommunityRequest, MyRequestToJoinCommunityAccepted,
# MyRequestToJoinCommunityRejected)
else:
self.notificationCheck(title, message, details, "")

View File

@ -31,8 +31,14 @@ QtObject:
isCommunitySection: bool, isSectionActive: bool, chatId: string, isChatActive: bool, messageId: string,
notificationType: int, isOneToOne: bool, isGroupChat: bool) {.signal.}
proc showNewContactRequestNotification*(self: GlobalEvents, title: string, message: string, sectionId: string)
{.signal.}
proc showNewContactRequestNotification*(self: GlobalEvents, title: string, message: string,
sectionId: string) {.signal.}
proc showAcceptedContactRequest*(self: GlobalEvents, title: string, message: string,
sectionId: string) {.signal.}
proc showContactRemoved*(self: GlobalEvents, title: string, message: string,
sectionId: string) {.signal.}
proc newCommunityMembershipRequestNotification*(self: GlobalEvents, title: string, message: string,
sectionId: string) {.signal.}
@ -43,7 +49,4 @@ QtObject:
proc myRequestToJoinCommunityRejected*(self: GlobalEvents, title: string, message: string,
sectionId: string) {.signal.}
proc showAcceptedContactRequest*(self: GlobalEvents, title: string, message: string,
sectionId: string) {.signal.}
proc meMentionedIconBadgeNotification*(self: GlobalEvents, allMentions: int) {.signal.}

View File

@ -1237,7 +1237,8 @@ method displayEphemeralNotification*[T](self: Module[T], title: string, subTitle
self.displayEphemeralNotification(title, subTitle, "", false, EphemeralNotificationType.Default.int, "", details)
elif(details.notificationType == NotificationType.NewContactRequest or
details.notificationType == NotificationType.IdentityVerificationRequest):
details.notificationType == NotificationType.IdentityVerificationRequest or
details.notificationType == NotificationType.ContactRemoved):
self.displayEphemeralNotification(title, subTitle, "contact", false, EphemeralNotificationType.Default.int, "", details)
elif(details.notificationType == NotificationType.AcceptedContactRequest):

View File

@ -450,6 +450,7 @@ QtObject:
if self.contacts[publicKey].dto.added and not self.contacts[publicKey].dto.removed and contact.added and not contact.removed:
signal = SIGNAL_CONTACT_UPDATED
if contact.removed:
singletonInstance.globalEvents.showContactRemoved("Contact removed", fmt "You removed {contact.displayName} as a contact", contact.id)
signal = SIGNAL_CONTACT_REMOVED
self.contacts[publicKey] = self.constructContactDetails(contact)