From 05e682cdc2d795c9fd8cb093610c1125197f5e0c Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 5 Oct 2020 10:53:09 +1100 Subject: [PATCH] enable back swarm polling when we get added back to a group --- ts/receiver/mediumGroups.ts | 5 +++-- ts/session/snode_api/swarmPolling.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ts/receiver/mediumGroups.ts b/ts/receiver/mediumGroups.ts index a0fe3eb75..7c9582b3a 100644 --- a/ts/receiver/mediumGroups.ts +++ b/ts/receiver/mediumGroups.ts @@ -331,6 +331,8 @@ async function handleMediumGroupChange( // Enable typing: maybeConvo.set('isKickedFromGroup', false); maybeConvo.set('left', false); + // Subscribe to this group id + window.SwarmPolling.addGroupId(new PubKey(groupId)); maybeConvo.updateTextInputState(); } } @@ -342,8 +344,7 @@ async function handleMediumGroupChange( const userSenderKey = await createSenderKeyForGroup(groupId, primary); window.log.warn( 'Sharing our new senderKey with remainingMembers via message', - members, - userSenderKey + members ); await shareSenderKeys(groupId, members, userSenderKey); diff --git a/ts/session/snode_api/swarmPolling.ts b/ts/session/snode_api/swarmPolling.ts index ac2eaacc7..0f3407c27 100644 --- a/ts/session/snode_api/swarmPolling.ts +++ b/ts/session/snode_api/swarmPolling.ts @@ -51,12 +51,16 @@ export class SwarmPolling { } public addGroupId(pubkey: PubKey) { - this.groupPubkeys.push(pubkey); + if (this.groupPubkeys.findIndex(m => m.key === pubkey.key) === -1) { + this.groupPubkeys.push(pubkey); + } } public addPubkey(pk: PubKey | string) { const pubkey = PubKey.cast(pk); - this.pubkeys.push(pubkey); + if (this.pubkeys.findIndex(m => m.key === pubkey.key) === -1) { + this.pubkeys.push(pubkey); + } } public removePubkey(pk: PubKey | string) {