Rename functions to be less confusing

pull/834/head
Mikunj Varsani 6 years ago
parent a75ef365b8
commit 4f6dd7a8d5

@ -198,15 +198,20 @@
isOnline() { isOnline() {
return this.isMe() || this.get('isOnline'); return this.isMe() || this.get('isOnline');
}, },
isMe() { isMe() {
return this.isOurLocalDevice() || this.isOurPrimaryDevice();
},
isOurPrimaryDevice() {
return this.id === window.storage.get('primaryDevicePubKey'); return this.id === window.storage.get('primaryDevicePubKey');
}, },
async isOurDevice() { async isOurDevice() {
const ourDevices = await window.libloki.storage.getPairedDevicesFor( const ourDevices = await window.libloki.storage.getPairedDevicesFor(
this.ourNumber this.ourNumber
); );
return this.id === this.ourNumber || ourDevices.includes(this.id); return this.isOurLocalDevice() || ourDevices.includes(this.id);
},
isOurLocalDevice() {
return this.id === this.ourNumber;
}, },
isPublic() { isPublic() {
return !!(this.id && this.id.match(/^publicChat:/)); return !!(this.id && this.id.match(/^publicChat:/));
@ -892,9 +897,6 @@
throw new Error('Invalid friend request state'); throw new Error('Invalid friend request state');
} }
}, },
isOurConversation() {
return this.id === this.ourNumber;
},
isSecondaryDevice() { isSecondaryDevice() {
return !!this.get('secondaryStatus'); return !!this.get('secondaryStatus');
}, },

@ -411,6 +411,10 @@ MessageSender.prototype = {
const ourNumber = textsecure.storage.user.getNumber(); const ourNumber = textsecure.storage.user.getNumber();
// Note: Since we're just doing independant tasks,
// using `async` in the `forEach` loop should be fine.
// If however we want to use the results from forEach then
// we would need to convert this to a Promise.all(numbers.map(...))
numbers.forEach(async number => { numbers.forEach(async number => {
// Note: if we are sending a private group message, we do our best to // Note: if we are sending a private group message, we do our best to
// ensure we have signal protocol sessions with every member, but if we // ensure we have signal protocol sessions with every member, but if we

@ -55,11 +55,8 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
const conversations = window.getConversations() || []; const conversations = window.getConversations() || [];
const conversationList = conversations.filter((conversation: any) => { const conversationList = conversations.filter((conversation: any) => {
// TODO: We need to handle the case with > 1 secondary device
const isOurDevice =
conversation.isMe() || conversation.isOurConversation();
return ( return (
!isOurDevice && !conversation.isMe() &&
conversation.isPrivate() && conversation.isPrivate() &&
!conversation.isSecondaryDevice() && !conversation.isSecondaryDevice() &&
conversation.isFriend() conversation.isFriend()

Loading…
Cancel
Save