Added notification when receiving a friend request and when a friend request was accepted.

pull/41/head
Mikunj 7 years ago
parent 5a428af873
commit dfae580ffa

@ -487,6 +487,20 @@
} }
await this.updatePendingFriendRequests(); await this.updatePendingFriendRequests();
this.getNotificationIcon().then(iconUrl => {
window.log.info('Add notification for friend request updated', {
conversationId: this.idForLogging(),
});
Whisper.Notifications.add({
conversationId: this.id,
iconUrl,
isExpiringMessage: false,
message: `Accepted your friend request`,
messageSentAt: Date.now(),
title: this.getTitle(),
});
});
}, },
async onFriendRequestTimedOut() { async onFriendRequestTimedOut() {
this.updateTextInputState(); this.updateTextInputState();
@ -756,13 +770,13 @@
Message: Whisper.Message, Message: Whisper.Message,
}); });
this.trigger( const whisperMessage = new Whisper.Message({
'newmessage', ...message,
new Whisper.Message({ id,
...message, });
id,
}) this.trigger('newmessage', whisperMessage);
); this.notify(whisperMessage);
}, },
async addVerifiedChange(verifiedChangeId, verified, providedOptions) { async addVerifiedChange(verifiedChangeId, verified, providedOptions) {
const options = providedOptions || {}; const options = providedOptions || {};
@ -2027,7 +2041,7 @@
}, },
notify(message) { notify(message) {
if (!message.isIncoming()) { if (!(message.isIncoming() || message.isFriendRequest())) {
return Promise.resolve(); return Promise.resolve();
} }
const conversationId = this.id; const conversationId = this.id;

@ -192,6 +192,7 @@
getNotificationText() { getNotificationText() {
const description = this.getDescription(); const description = this.getDescription();
if (description) { if (description) {
if (this.isFriendRequest()) return `Friend Request: ${description}`;
return description; return description;
} }
if (this.get('attachments').length > 0) { if (this.get('attachments').length > 0) {

Loading…
Cancel
Save