From 760b99587ae4957ce40767ea1b33d9bbfb370329 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 19 Oct 2021 17:27:18 +1100 Subject: [PATCH] make sure to poll quicker if we get >95 messages on one polling --- ts/session/snode_api/swarmPolling.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ts/session/snode_api/swarmPolling.ts b/ts/session/snode_api/swarmPolling.ts index 56a7a7551..437c32333 100644 --- a/ts/session/snode_api/swarmPolling.ts +++ b/ts/session/snode_api/swarmPolling.ts @@ -232,12 +232,19 @@ export class SwarmPolling { window?.log?.info( `Polled for group(${ed25519Str(pubkey.key)}):, got ${messages.length} messages back.` ); + let lastPolledTimestamp = Date.now(); + if (messages.length >= 95) { + // if we get 95 messages or more back, it means there are probably more than this + // so make sure to retry the polling in the next 5sec by marking the last polled timestamp way before that it is really + // this is a kind of hack + lastPolledTimestamp = Date.now() - SWARM_POLLING_TIMEOUT.INACTIVE - 5 * 1000; + } // update the last fetched timestamp this.groupPolling = this.groupPolling.map(group => { if (PubKey.isEqual(pubkey, group.pubkey)) { return { ...group, - lastPolledTimestamp: Date.now(), + lastPolledTimestamp, }; } return group;