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

pull/41/head
Mikunj 6 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();
@ -755,14 +769,14 @@
const id = await window.Signal.Data.saveMessage(message, { const id = await window.Signal.Data.saveMessage(message, {
Message: Whisper.Message, Message: Whisper.Message,
}); });
const whisperMessage = new Whisper.Message({
...message,
id,
});
this.trigger( this.trigger('newmessage', whisperMessage);
'newmessage', this.notify(whisperMessage);
new Whisper.Message({
...message,
id,
})
);
}, },
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