Mitigation for gappy/limited sync responses in SPA mode

This commit is contained in:
Hugh Nimmo-Smith
2024-11-12 13:29:31 +00:00
parent 83fa9661cf
commit ccd40b79e1
2 changed files with 22 additions and 1 deletions

View File

@@ -9,8 +9,10 @@ import { IndexedDBStore } from "matrix-js-sdk/src/store/indexeddb";
import { MemoryStore } from "matrix-js-sdk/src/store/memory";
import {
createClient,
Filter,
ICreateClientOpts,
Preset,
RoomEvent,
Visibility,
} from "matrix-js-sdk/src/matrix";
import { ClientEvent } from "matrix-js-sdk/src/client";
@@ -165,7 +167,20 @@ export async function initClient(
// Otherwise, a sync may complete before the listener gets applied,
// and we will miss it.
const syncPromise = waitForSync(client);
await client.startClient({ clientWellKnownPollPeriod: 60 * 10 });
await client.startClient({
clientWellKnownPollPeriod: 60 * 10,
// ask for a high limit to try and avoid gappy syncs
filter: Filter.fromJson(undefined, "element-call", {
room: {
timeline: {
limit: 1000,
},
},
}),
// we ask for 20 past message to try and get some recent context
// n.b. past reactions are not guaranteed to be visible
initialSyncLimit: 20,
});
await syncPromise;
return client;