code cleanup.

pull/33/head
Mikunj 7 years ago
parent dc1e42a2e4
commit f2dbdff548

@ -259,9 +259,8 @@
} }
); );
// We are most likely to find the friend request in the more recent conversations first
// Get the messages that are matching the direction and the friendStatus // Get the messages that are matching the direction and the friendStatus
return messages.models.reverse().filter(m => { return messages.models.filter(m => {
return (m.attributes.direction === direction && m.attributes.friendStatus === 'pending') return (m.attributes.direction === direction && m.attributes.friendStatus === 'pending')
}); });
}, },
@ -437,17 +436,6 @@
return this.get('keyExchangeCompleted') || false; return this.get('keyExchangeCompleted') || false;
}, },
async setKeyExchangeCompleted(completed) {
if (typeof completed !== 'boolean') {
throw new Error('setKeyExchangeCompleted expects a bool');
}
this.set({ keyExchangeCompleted: completed });
await window.Signal.Data.updateConversation(this.id, this.attributes, {
Conversation: Whisper.Conversation,
});
},
getFriendRequestStatus() { getFriendRequestStatus() {
return this.get('friendRequestStatus'); return this.get('friendRequestStatus');
}, },
@ -682,6 +670,7 @@
}) })
); );
}, },
// Remove the message locally from our conversation
async _removeMessage(id) { async _removeMessage(id) {
await window.Signal.Data.removeMessage(id, { Message: Whisper.Message }); await window.Signal.Data.removeMessage(id, { Message: Whisper.Message });
const existing = this.messageCollection.get(id); const existing = this.messageCollection.get(id);
@ -693,7 +682,7 @@
// This will add a message which will allow the user to reply to a friend request // This will add a message which will allow the user to reply to a friend request
async addFriendRequest(body, options = {}) { async addFriendRequest(body, options = {}) {
const _options = { const _options = {
status: 'pending', friendStatus: 'pending',
direction: 'incoming', direction: 'incoming',
preKeyBundle: null, preKeyBundle: null,
...options, ...options,
@ -751,7 +740,7 @@
unread: 1, unread: 1,
from: this.id, from: this.id,
to: this.ourNumber, to: this.ourNumber,
friendStatus: _options.status, friendStatus: _options.friendStatus,
direction: _options.direction, direction: _options.direction,
body, body,
preKeyBundle: _options.preKeyBundle, preKeyBundle: _options.preKeyBundle,

Loading…
Cancel
Save