Fixed review issues.

Fixed lint error.
pull/41/head
Mikunj 7 years ago
parent 4f4ebf3ddd
commit 17e5c861a1

@ -460,13 +460,13 @@
} }
} }
}, },
async onFriendRequestAccepted(updateUnread = false) { async onFriendRequestAccepted({ updateUnread }) {
// Make sure we don't keep incrementing the unread count // Make sure we don't keep incrementing the unread count
const unreadCount = this.isKeyExchangeCompleted() || !updateUnread ? {} : { unreadCount: this.get('unreadCount') + 1 }; const unreadCount = this.isKeyExchangeCompleted() || !updateUnread ? {} : { unreadCount: this.get('unreadCount') + 1 };
this.set({ this.set({
friendRequestStatus: null, friendRequestStatus: null,
keyExchangeCompleted: true, keyExchangeCompleted: true,
...unreadCount ...unreadCount,
}); });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await window.Signal.Data.updateConversation(this.id, this.attributes, {
@ -478,16 +478,17 @@
// Update any pending outgoing messages // Update any pending outgoing messages
const pending = await this.getPendingFriendRequests('outgoing'); const pending = await this.getPendingFriendRequests('outgoing');
for (const request of pending) { await Promise.all(
// Only update successfully sent requests pending.map(async request => {
if (request.hasErrors()) continue; if (request.hasErrors()) return;
request.set({ friendStatus: 'accepted' }); request.set({ friendStatus: 'accepted' });
await window.Signal.Data.saveMessage(request.attributes, { await window.Signal.Data.saveMessage(request.attributes, {
Message: Whisper.Message, Message: Whisper.Message,
}); });
this.trigger('updateMessage', request); this.trigger('updateMessage', request);
} })
);
await this.updatePendingFriendRequests(); await this.updatePendingFriendRequests();
@ -2034,7 +2035,8 @@
notify(message) { notify(message) {
if (!message.isIncoming()) { if (!message.isIncoming()) {
if (message.isFriendRequest()) return this.notifyFriendRequest(message.get('source'), 'requested'); if (message.isFriendRequest())
return this.notifyFriendRequest(message.get('source'), 'requested');
return Promise.resolve(); return Promise.resolve();
} }
const conversationId = this.id; const conversationId = this.id;

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

@ -1024,11 +1024,11 @@ MessageReceiver.prototype.extend({
if (savePreKey) { if (savePreKey) {
await this.handlePreKeyBundleMessage( await this.handlePreKeyBundleMessage(
envelope.source, envelope.source,
this.decodePreKeyBundleMessage(content.preKeyBundleMessage), this.decodePreKeyBundleMessage(content.preKeyBundleMessage)
); );
// Update the conversation // Update the conversation
await conversation.onFriendRequestAccepted(true); await conversation.onFriendRequestAccepted({ updateUnread: true });
} }
} }
} }

Loading…
Cancel
Save