From 3f650a1d159cb735031f0e88bd52bd4692dc4b19 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 4 May 2020 12:55:30 +1000 Subject: [PATCH 01/10] prevent note to self on unlink from slave --- js/background.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/background.js b/js/background.js index e9f43c901..ddfa0a38e 100644 --- a/js/background.js +++ b/js/background.js @@ -1365,6 +1365,11 @@ }); Whisper.events.on('deviceUnpairingRequested', async (pubKey, callback) => { + const isSecondaryDevice = !!textsecure.storage.get('isSecondaryDevice'); + if (isSecondaryDevice){ + return; + } + await libloki.storage.removePairingAuthorisationForSecondaryPubKey( pubKey ); From a5b110121614addb15757a5daccbd01cec48aa65 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 4 May 2020 13:53:25 +1000 Subject: [PATCH 02/10] Slave unlinking & FR dup fix --- js/background.js | 4 ++-- ts/components/session/LeftPaneContactSection.tsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/background.js b/js/background.js index ddfa0a38e..0b811f59d 100644 --- a/js/background.js +++ b/js/background.js @@ -1366,10 +1366,10 @@ Whisper.events.on('deviceUnpairingRequested', async (pubKey, callback) => { const isSecondaryDevice = !!textsecure.storage.get('isSecondaryDevice'); - if (isSecondaryDevice){ + if (isSecondaryDevice) { return; } - + await libloki.storage.removePairingAuthorisationForSecondaryPubKey( pubKey ); diff --git a/ts/components/session/LeftPaneContactSection.tsx b/ts/components/session/LeftPaneContactSection.tsx index dd2ae21df..02ab2384f 100644 --- a/ts/components/session/LeftPaneContactSection.tsx +++ b/ts/components/session/LeftPaneContactSection.tsx @@ -321,9 +321,10 @@ export class LeftPaneContactSection extends React.Component { private renderList() { const { sentFriendsRequest } = this.props; + const visibleFriendRequests = sentFriendsRequest.filter(device => !device.isSecondary); const friends = window.getFriendsFromContacts(this.props.friends); const length = Number(sentFriendsRequest.length) + Number(friends.length); - const combined = [...sentFriendsRequest, ...friends]; + const combined = [...visibleFriendRequests, ...friends]; const list = (
From 3c2320635a3db2d10d262940b46871db8e918d82 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 4 May 2020 15:47:40 +1000 Subject: [PATCH 03/10] Filter secondaries --- ts/components/session/LeftPaneContactSection.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ts/components/session/LeftPaneContactSection.tsx b/ts/components/session/LeftPaneContactSection.tsx index 02ab2384f..c78e067e7 100644 --- a/ts/components/session/LeftPaneContactSection.tsx +++ b/ts/components/session/LeftPaneContactSection.tsx @@ -321,9 +321,13 @@ export class LeftPaneContactSection extends React.Component { private renderList() { const { sentFriendsRequest } = this.props; - const visibleFriendRequests = sentFriendsRequest.filter(device => !device.isSecondary); + + const visibleFriendRequests = sentFriendsRequest.filter( + device => !device.isSecondary + ); + const friends = window.getFriendsFromContacts(this.props.friends); - const length = Number(sentFriendsRequest.length) + Number(friends.length); + const length = Number(visibleFriendRequests.length) + Number(friends.length); const combined = [...visibleFriendRequests, ...friends]; const list = ( From a429771b927911b45be7dfe35f9a055fa1d87f70 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 4 May 2020 17:02:53 +1000 Subject: [PATCH 04/10] Linted --- ts/components/session/LeftPaneContactSection.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ts/components/session/LeftPaneContactSection.tsx b/ts/components/session/LeftPaneContactSection.tsx index c78e067e7..6a8cce476 100644 --- a/ts/components/session/LeftPaneContactSection.tsx +++ b/ts/components/session/LeftPaneContactSection.tsx @@ -327,7 +327,8 @@ export class LeftPaneContactSection extends React.Component { ); const friends = window.getFriendsFromContacts(this.props.friends); - const length = Number(visibleFriendRequests.length) + Number(friends.length); + const length = + Number(visibleFriendRequests.length) + Number(friends.length); const combined = [...visibleFriendRequests, ...friends]; const list = ( From 2b7df8e40bf96a5d69f30b87ac8612fd6c8fc5bb Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 12 May 2020 09:29:10 +1000 Subject: [PATCH 05/10] Filtering groups fromstate --- js/models/conversations.js | 1 + package.json | 3 +- .../session/LeftPaneContactSection.tsx | 13 ++++--- .../session/LeftPaneMessageSection.tsx | 4 +++ ts/state/ducks/conversations.ts | 1 + ts/state/selectors/conversations.ts | 36 +++++++++++++++++-- ts/test/state/selectors/conversations_test.ts | 5 +++ 7 files changed, 54 insertions(+), 9 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 48c6781df..a4410b279 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -595,6 +595,7 @@ isRss: this.isRss(), isClosable: this.isClosable(), isTyping: typingKeys.length > 0, + lastUpdated: this.get('timestamp'), name: this.getName(), profileName: this.getProfileName(), diff --git a/package.json b/package.json index 3472e45d7..2237adb42 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,12 @@ "start-multi2": "cross-env NODE_APP_INSTANCE=2 electron .", "start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod electron .", "start-prod-multi": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod1 electron .", + "start-prod-multi2": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod2 electron .", "start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=1 electron .", "start-swarm-test-2": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=2 electron .", "grunt": "grunt", "icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build", - "generate": "yarn icon-gen && yarn grunt", + "generate": "yarn icon-gen && yarn grunt", "build-release": "cross-env SIGNAL_ENV=production npm run build -- --config.directories.output=release", "build-module-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js", "clean-module-protobuf": "rm -f ts/protobuf/compiled.d.ts ts/protobuf/compiled.js", diff --git a/ts/components/session/LeftPaneContactSection.tsx b/ts/components/session/LeftPaneContactSection.tsx index 6a8cce476..d29cd38cb 100644 --- a/ts/components/session/LeftPaneContactSection.tsx +++ b/ts/components/session/LeftPaneContactSection.tsx @@ -247,6 +247,8 @@ export class LeftPaneContactSection extends React.Component { const hasReceivedFriendRequest = this.props.receivedFriendsRequest.length > 0; + console.log('[vince] this.props:', this.props); + return (
{this.renderList()} @@ -322,14 +324,15 @@ export class LeftPaneContactSection extends React.Component { private renderList() { const { sentFriendsRequest } = this.props; - const visibleFriendRequests = sentFriendsRequest.filter( - device => !device.isSecondary - ); + console.log('[vince] this.props.friends:', this.props.friends); + console.log('[vince] sentFriendsRequest:', sentFriendsRequest); const friends = window.getFriendsFromContacts(this.props.friends); const length = - Number(visibleFriendRequests.length) + Number(friends.length); - const combined = [...visibleFriendRequests, ...friends]; + Number(sentFriendsRequest.length) + Number(friends.length); + + // prevent where friends and send FR showing two entries + const combined = [...new Set ([...sentFriendsRequest, ...friends])]; const list = (
diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index e29b942b1..3a55767b0 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -203,6 +203,10 @@ export class LeftPaneMessageSection extends React.Component { } public render(): JSX.Element { + const conversations = this.getCurrentConversations(); + console.log('[vince] conversations:', conversations); + + return (
{this.renderHeader()} diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 06ff8f458..e7ea0e406 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -53,6 +53,7 @@ export type ConversationType = { isSelected: boolean; isTyping: boolean; isFriend?: boolean; + isSecondary?: boolean; hasReceivedFriendRequest?: boolean; hasSentFriendRequest?: boolean; }; diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 90e175192..eb9d8289c 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -9,6 +9,10 @@ import { ConversationType, } from '../ducks/conversations'; +import { + getPrimaryDeviceFor +} from '../../../js/modules/data'; + import { getIntl, getRegionCode, getUserNumber } from './user'; import { PropsData as ConversationListItemPropsType } from '../../components/ConversationListItem'; @@ -102,6 +106,8 @@ export const _getLeftPaneLists = ( sentFriendsRequest: Array; unreadCount: number; } => { + const _ = window.Lodash; + const values = Object.values(lookup); const sorted = values.sort(comparator); @@ -114,6 +120,30 @@ export const _getLeftPaneLists = ( const max = sorted.length; let unreadCount = 0; + // Map pubkeys to their primary pubkey so you don't need to call getPrimaryDeviceFor + // every time. + + const filterToPrimary = async (conversation: ConversationType, filerGroup: Array) => { + // Used to ensure that only the primary device gets added to LeftPane filtered groups + // Get one result per user. Dont just ignore secondaries, in case + // a user hasn't synced with primary but FR or contact is duplicated. + + const primaryPubkey = conversation.isSecondary + ? await getPrimaryDeviceFor(conversation.id) + : conversation.id; + + const primaryConversation = conversation.isSecondary + ? conversations.find(c => c.id === primaryPubkey) + : conversation; + + if (!_.includes(filerGroup, primaryConversation)) { + // Push secondary to array only if private pubkey not found + filerGroup.push(primaryConversation || conversation); + } + + return primaryConversation; + }; + for (let i = 0; i < max; i += 1) { let conversation = sorted[i]; @@ -125,11 +155,11 @@ export const _getLeftPaneLists = ( } if (conversation.isFriend && conversation.activeAt !== undefined) { - friends.push(conversation); + void filterToPrimary(conversation, friends); } if (conversation.hasReceivedFriendRequest) { - receivedFriendsRequest.push(conversation); + void filterToPrimary(conversation, receivedFriendsRequest); } else if ( unreadCount < 9 && conversation.isFriend && @@ -138,7 +168,7 @@ export const _getLeftPaneLists = ( unreadCount += conversation.unreadCount; } if (conversation.hasSentFriendRequest) { - sentFriendsRequest.push(conversation); + void filterToPrimary(conversation, sentFriendsRequest); } if (!conversation.activeAt) { diff --git a/ts/test/state/selectors/conversations_test.ts b/ts/test/state/selectors/conversations_test.ts index 63b6cd9e9..ce3681a7e 100644 --- a/ts/test/state/selectors/conversations_test.ts +++ b/ts/test/state/selectors/conversations_test.ts @@ -19,6 +19,7 @@ describe('state/selectors/conversations', () => { timestamp: 0, phoneNumber: 'notused', isArchived: false, + isSecondary: false, type: 'direct', isMe: false, @@ -35,6 +36,7 @@ describe('state/selectors/conversations', () => { timestamp: 20, phoneNumber: 'notused', isArchived: false, + isSecondary: false, type: 'direct', isMe: false, @@ -51,6 +53,7 @@ describe('state/selectors/conversations', () => { timestamp: 20, phoneNumber: 'notused', isArchived: false, + isSecondary: false, type: 'direct', isMe: false, @@ -67,6 +70,7 @@ describe('state/selectors/conversations', () => { timestamp: 20, phoneNumber: 'notused', isArchived: false, + isSecondary: false, type: 'direct', isMe: false, @@ -83,6 +87,7 @@ describe('state/selectors/conversations', () => { timestamp: 30, phoneNumber: 'notused', isArchived: false, + isSecondary: false, type: 'direct', isMe: false, From 7d803280e8a532c220b1f29901c7b1e7d9707710 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 12 May 2020 13:15:58 +1000 Subject: [PATCH 06/10] halfway --- js/models/conversations.js | 2 +- ts/state/ducks/conversations.ts | 1 + ts/state/selectors/conversations.ts | 84 +++++++++++++++---- ts/test/state/selectors/conversations_test.ts | 5 ++ 4 files changed, 73 insertions(+), 19 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index a4410b279..822600f19 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -595,7 +595,6 @@ isRss: this.isRss(), isClosable: this.isClosable(), isTyping: typingKeys.length > 0, - lastUpdated: this.get('timestamp'), name: this.getName(), profileName: this.getProfileName(), @@ -608,6 +607,7 @@ hasSentFriendRequest: this.hasSentFriendRequest(), isBlocked: this.isBlocked(), isSecondary: !!this.get('secondaryStatus'), + primaryDevice: this.getPrimaryDevicePubKey(), phoneNumber: format(this.id, { ourRegionCode: regionCode, }), diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index e7ea0e406..219c66377 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -54,6 +54,7 @@ export type ConversationType = { isTyping: boolean; isFriend?: boolean; isSecondary?: boolean; + primaryDevice: string; hasReceivedFriendRequest?: boolean; hasSentFriendRequest?: boolean; }; diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index eb9d8289c..b4304660a 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -9,10 +9,6 @@ import { ConversationType, } from '../ducks/conversations'; -import { - getPrimaryDeviceFor -} from '../../../js/modules/data'; - import { getIntl, getRegionCode, getUserNumber } from './user'; import { PropsData as ConversationListItemPropsType } from '../../components/ConversationListItem'; @@ -123,25 +119,77 @@ export const _getLeftPaneLists = ( // Map pubkeys to their primary pubkey so you don't need to call getPrimaryDeviceFor // every time. - const filterToPrimary = async (conversation: ConversationType, filerGroup: Array) => { + const filterToPrimary = (conversation: ConversationType, group: Array) => { // Used to ensure that only the primary device gets added to LeftPane filtered groups // Get one result per user. Dont just ignore secondaries, in case // a user hasn't synced with primary but FR or contact is duplicated. - const primaryPubkey = conversation.isSecondary - ? await getPrimaryDeviceFor(conversation.id) - : conversation.id; + // You can't just get the primary device for each conversation, as different + // devices might have seperate FR and contacts status, etc. - const primaryConversation = conversation.isSecondary - ? conversations.find(c => c.id === primaryPubkey) - : conversation; + const primaryPubkey = conversation.primaryDevice; + const groupHasPrimary = group.some(c => c.id === primaryPubkey); - if (!_.includes(filerGroup, primaryConversation)) { - // Push secondary to array only if private pubkey not found - filerGroup.push(primaryConversation || conversation); + if (!groupHasPrimary) { + group.push(conversation); } - return primaryConversation; + const constructedGroup = conversations.filter(c => _.includes(group, c.id)); + + const newGroup = constructedGroup.filter(c => { + if ( + c.isSecondary && + group.some(g => g.id === c.primaryDevice) + ) { + return false; + } + + return true; + }); + + console.log('[group] primaryPubkey:', primaryPubkey); + console.log('[group] groupHasPrimary:', groupHasPrimary); + + console.log('[group] group:', group); + console.log('[vince] newGroup:', newGroup); + + // const isPrimary = !conversation.isSecondary; + + // // If no secondary or primary currently in group, add + // if (!groupHasPrimary) { + // group.push(conversation); + // } + + // if (clg) { + // console.log('[group] conversation:', conversation); + // console.log('[group] primaryPubkey:', primaryPubkey); + // console.log('[group] group:', group); + // console.log('[group] groupHasPrimary:', groupHasPrimary); + + // const qwer = conversations.filter(c => _.includes(group, c.id)); + // console.log('[group] constructedGroup:', qwer); + // } + + // // If primary, but secondary already added to group, remove secondary + // if (isPrimary) { + // // Build up propsData into ConversationType + // const constructedGroup = conversations.filter(c => _.includes(group, c.id)); + + // console.log('[group] primary, but secondary already added to group, remove secondary:'); + + // constructedGroup.every(c => { + // if (c.primaryDevice === primaryPubkey) { + // const secondaryIndex = group.indexOf(c); + // group.splice(secondaryIndex, 1); + + // // Early break; removed redundant secondary + // return false; + // } + + // return true; + // }); + // } + }; for (let i = 0; i < max; i += 1) { @@ -155,11 +203,11 @@ export const _getLeftPaneLists = ( } if (conversation.isFriend && conversation.activeAt !== undefined) { - void filterToPrimary(conversation, friends); + filterToPrimary(true, conversation, friends); } if (conversation.hasReceivedFriendRequest) { - void filterToPrimary(conversation, receivedFriendsRequest); + filterToPrimary(false, conversation, receivedFriendsRequest); } else if ( unreadCount < 9 && conversation.isFriend && @@ -168,7 +216,7 @@ export const _getLeftPaneLists = ( unreadCount += conversation.unreadCount; } if (conversation.hasSentFriendRequest) { - void filterToPrimary(conversation, sentFriendsRequest); + filterToPrimary(false, conversation, sentFriendsRequest); } if (!conversation.activeAt) { diff --git a/ts/test/state/selectors/conversations_test.ts b/ts/test/state/selectors/conversations_test.ts index ce3681a7e..6bc3f65ec 100644 --- a/ts/test/state/selectors/conversations_test.ts +++ b/ts/test/state/selectors/conversations_test.ts @@ -20,6 +20,7 @@ describe('state/selectors/conversations', () => { phoneNumber: 'notused', isArchived: false, isSecondary: false, + primaryDevice: 'id1', type: 'direct', isMe: false, @@ -37,6 +38,7 @@ describe('state/selectors/conversations', () => { phoneNumber: 'notused', isArchived: false, isSecondary: false, + primaryDevice: 'id2', type: 'direct', isMe: false, @@ -54,6 +56,7 @@ describe('state/selectors/conversations', () => { phoneNumber: 'notused', isArchived: false, isSecondary: false, + primaryDevice: 'id3', type: 'direct', isMe: false, @@ -71,6 +74,7 @@ describe('state/selectors/conversations', () => { phoneNumber: 'notused', isArchived: false, isSecondary: false, + primaryDevice: 'id4', type: 'direct', isMe: false, @@ -88,6 +92,7 @@ describe('state/selectors/conversations', () => { phoneNumber: 'notused', isArchived: false, isSecondary: false, + primaryDevice: 'id5', type: 'direct', isMe: false, From 10ccea5ec81a11d105fd316b2aafc7a434ffe625 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 12 May 2020 13:27:22 +1000 Subject: [PATCH 07/10] tight filtering --- ts/state/selectors/conversations.ts | 77 +++++------------------------ 1 file changed, 13 insertions(+), 64 deletions(-) diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index b4304660a..6a3d49a45 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -119,7 +119,7 @@ export const _getLeftPaneLists = ( // Map pubkeys to their primary pubkey so you don't need to call getPrimaryDeviceFor // every time. - const filterToPrimary = (conversation: ConversationType, group: Array) => { + const filterToPrimary = (group: Array) => { // Used to ensure that only the primary device gets added to LeftPane filtered groups // Get one result per user. Dont just ignore secondaries, in case // a user hasn't synced with primary but FR or contact is duplicated. @@ -127,69 +127,15 @@ export const _getLeftPaneLists = ( // You can't just get the primary device for each conversation, as different // devices might have seperate FR and contacts status, etc. - const primaryPubkey = conversation.primaryDevice; - const groupHasPrimary = group.some(c => c.id === primaryPubkey); - - if (!groupHasPrimary) { - group.push(conversation); - } - - const constructedGroup = conversations.filter(c => _.includes(group, c.id)); - - const newGroup = constructedGroup.filter(c => { - if ( - c.isSecondary && - group.some(g => g.id === c.primaryDevice) - ) { - return false; - } - - return true; - }); - - console.log('[group] primaryPubkey:', primaryPubkey); - console.log('[group] groupHasPrimary:', groupHasPrimary); + // Build up propsData into ConversationType + const constructedGroup = conversations.filter(c => group.some(g => c.id === g.id)); + const filteredGroup = constructedGroup.filter(c => !(c.isSecondary && group.some(g => g.id === c.primaryDevice))); + console.log('[group] conversations:', conversations); console.log('[group] group:', group); - console.log('[vince] newGroup:', newGroup); - - // const isPrimary = !conversation.isSecondary; - - // // If no secondary or primary currently in group, add - // if (!groupHasPrimary) { - // group.push(conversation); - // } - - // if (clg) { - // console.log('[group] conversation:', conversation); - // console.log('[group] primaryPubkey:', primaryPubkey); - // console.log('[group] group:', group); - // console.log('[group] groupHasPrimary:', groupHasPrimary); - - // const qwer = conversations.filter(c => _.includes(group, c.id)); - // console.log('[group] constructedGroup:', qwer); - // } - - // // If primary, but secondary already added to group, remove secondary - // if (isPrimary) { - // // Build up propsData into ConversationType - // const constructedGroup = conversations.filter(c => _.includes(group, c.id)); - - // console.log('[group] primary, but secondary already added to group, remove secondary:'); - - // constructedGroup.every(c => { - // if (c.primaryDevice === primaryPubkey) { - // const secondaryIndex = group.indexOf(c); - // group.splice(secondaryIndex, 1); - - // // Early break; removed redundant secondary - // return false; - // } - - // return true; - // }); - // } + console.log('[group] filteredGroup:', filteredGroup); + return filteredGroup; }; for (let i = 0; i < max; i += 1) { @@ -203,11 +149,11 @@ export const _getLeftPaneLists = ( } if (conversation.isFriend && conversation.activeAt !== undefined) { - filterToPrimary(true, conversation, friends); + friends.push(conversation) } if (conversation.hasReceivedFriendRequest) { - filterToPrimary(false, conversation, receivedFriendsRequest); + receivedFriendsRequest.push(conversation) } else if ( unreadCount < 9 && conversation.isFriend && @@ -216,7 +162,7 @@ export const _getLeftPaneLists = ( unreadCount += conversation.unreadCount; } if (conversation.hasSentFriendRequest) { - filterToPrimary(false, conversation, sentFriendsRequest); + sentFriendsRequest.push(conversation); } if (!conversation.activeAt) { @@ -230,6 +176,9 @@ export const _getLeftPaneLists = ( } } + const vFriends = filterToPrimary(friends); + console.log('[group] vFriends:', vFriends); + return { conversations, archivedConversations, From 843be3921e4f58fa61dc93174baaffa7f0994ea7 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 12 May 2020 13:49:23 +1000 Subject: [PATCH 08/10] finalised --- package.json | 1 - .../session/LeftPaneContactSection.tsx | 14 ++--- .../session/LeftPaneMessageSection.tsx | 2 - ts/state/selectors/conversations.ts | 63 +++++++++---------- 4 files changed, 35 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 2237adb42..e7d11f4ca 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "start-multi2": "cross-env NODE_APP_INSTANCE=2 electron .", "start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod electron .", "start-prod-multi": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod1 electron .", - "start-prod-multi2": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod2 electron .", "start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=1 electron .", "start-swarm-test-2": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=2 electron .", "grunt": "grunt", diff --git a/ts/components/session/LeftPaneContactSection.tsx b/ts/components/session/LeftPaneContactSection.tsx index d29cd38cb..9221e9415 100644 --- a/ts/components/session/LeftPaneContactSection.tsx +++ b/ts/components/session/LeftPaneContactSection.tsx @@ -247,8 +247,6 @@ export class LeftPaneContactSection extends React.Component { const hasReceivedFriendRequest = this.props.receivedFriendsRequest.length > 0; - console.log('[vince] this.props:', this.props); - return (
{this.renderList()} @@ -324,15 +322,11 @@ export class LeftPaneContactSection extends React.Component { private renderList() { const { sentFriendsRequest } = this.props; - console.log('[vince] this.props.friends:', this.props.friends); - console.log('[vince] sentFriendsRequest:', sentFriendsRequest); - const friends = window.getFriendsFromContacts(this.props.friends); - const length = - Number(sentFriendsRequest.length) + Number(friends.length); - - // prevent where friends and send FR showing two entries - const combined = [...new Set ([...sentFriendsRequest, ...friends])]; + const length = Number(sentFriendsRequest.length) + Number(friends.length); + + // Prevent where friends and send FR showing two entries + const combined = [...new Set([...sentFriendsRequest, ...friends])]; const list = (
diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index 3a55767b0..e49ff79c9 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -204,8 +204,6 @@ export class LeftPaneMessageSection extends React.Component { public render(): JSX.Element { const conversations = this.getCurrentConversations(); - console.log('[vince] conversations:', conversations); - return (
diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 6a3d49a45..f11d53982 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -102,42 +102,18 @@ export const _getLeftPaneLists = ( sentFriendsRequest: Array; unreadCount: number; } => { - const _ = window.Lodash; - const values = Object.values(lookup); const sorted = values.sort(comparator); const conversations: Array = []; const archivedConversations: Array = []; - const friends: Array = []; - const receivedFriendsRequest: Array = []; - const sentFriendsRequest: Array = []; + const allFriends: Array = []; + const allReceivedFriendsRequest: Array = []; + const allSentFriendsRequest: Array = []; const max = sorted.length; let unreadCount = 0; - // Map pubkeys to their primary pubkey so you don't need to call getPrimaryDeviceFor - // every time. - - const filterToPrimary = (group: Array) => { - // Used to ensure that only the primary device gets added to LeftPane filtered groups - // Get one result per user. Dont just ignore secondaries, in case - // a user hasn't synced with primary but FR or contact is duplicated. - - // You can't just get the primary device for each conversation, as different - // devices might have seperate FR and contacts status, etc. - - // Build up propsData into ConversationType - const constructedGroup = conversations.filter(c => group.some(g => c.id === g.id)); - const filteredGroup = constructedGroup.filter(c => !(c.isSecondary && group.some(g => g.id === c.primaryDevice))); - - console.log('[group] conversations:', conversations); - console.log('[group] group:', group); - console.log('[group] filteredGroup:', filteredGroup); - - return filteredGroup; - }; - for (let i = 0; i < max; i += 1) { let conversation = sorted[i]; @@ -149,11 +125,11 @@ export const _getLeftPaneLists = ( } if (conversation.isFriend && conversation.activeAt !== undefined) { - friends.push(conversation) + allFriends.push(conversation); } if (conversation.hasReceivedFriendRequest) { - receivedFriendsRequest.push(conversation) + allReceivedFriendsRequest.push(conversation); } else if ( unreadCount < 9 && conversation.isFriend && @@ -162,7 +138,7 @@ export const _getLeftPaneLists = ( unreadCount += conversation.unreadCount; } if (conversation.hasSentFriendRequest) { - sentFriendsRequest.push(conversation); + allSentFriendsRequest.push(conversation); } if (!conversation.activeAt) { @@ -176,8 +152,31 @@ export const _getLeftPaneLists = ( } } - const vFriends = filterToPrimary(friends); - console.log('[group] vFriends:', vFriends); + const filterToPrimary = ( + group: Array + ) => { + // Used to ensure that only the primary device gets added to LeftPane filtered groups + + const constructedGroup = conversations.filter(c => + group.some(g => c.id === g.id) + ); + // tslint:disable-next-line: no-unnecessary-local-variable + const filteredGroup = constructedGroup.filter( + (c, idx) => + !( + c.isSecondary && + constructedGroup.some( + g => !g.isSecondary && g.id === constructedGroup[idx].primaryDevice + ) + ) + ); + + return filteredGroup; + }; + + const friends = filterToPrimary(allFriends); + const receivedFriendsRequest = filterToPrimary(allReceivedFriendsRequest); + const sentFriendsRequest = filterToPrimary(allSentFriendsRequest); return { conversations, From af48865c9256e652f46ee3340959d7fdbd463b02 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 12 May 2020 15:01:12 +1000 Subject: [PATCH 09/10] remove getconvs --- ts/components/session/LeftPaneMessageSection.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index e49ff79c9..e29b942b1 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -203,8 +203,6 @@ export class LeftPaneMessageSection extends React.Component { } public render(): JSX.Element { - const conversations = this.getCurrentConversations(); - return (
{this.renderHeader()} From c22ba999e7cf512f386fa89f0caf5ee314fc7115 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 12 May 2020 15:01:30 +1000 Subject: [PATCH 10/10] remove getconvs --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e7d11f4ca..3472e45d7 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "start-swarm-test-2": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=2 electron .", "grunt": "grunt", "icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build", - "generate": "yarn icon-gen && yarn grunt", + "generate": "yarn icon-gen && yarn grunt", "build-release": "cross-env SIGNAL_ENV=production npm run build -- --config.directories.output=release", "build-module-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js", "clean-module-protobuf": "rm -f ts/protobuf/compiled.d.ts ts/protobuf/compiled.js",