mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-24 00:38:31 +08:00
Mitigation for gappy/limited sync responses in SPA mode
This commit is contained in:
parent
83fa9661cf
commit
aac8fa1059
@ -184,6 +184,10 @@ export const ReactionsProvider = ({
|
|||||||
// This effect handles any *live* reaction/redactions in the room.
|
// This effect handles any *live* reaction/redactions in the room.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const reactionTimeouts = new Set<number>();
|
const reactionTimeouts = new Set<number>();
|
||||||
|
// TODO: this should be somewhere more sensible
|
||||||
|
const handleTimelineReset = (): void => {
|
||||||
|
logger.warn("Received TimelineReset indicating limited sync response");
|
||||||
|
};
|
||||||
const handleReactionEvent = (event: MatrixEvent): void => {
|
const handleReactionEvent = (event: MatrixEvent): void => {
|
||||||
// Decrypted events might come from a different room
|
// Decrypted events might come from a different room
|
||||||
if (event.getRoomId() !== room.roomId) return;
|
if (event.getRoomId() !== room.roomId) return;
|
||||||
@ -297,6 +301,7 @@ export const ReactionsProvider = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
room.on(MatrixRoomEvent.TimelineReset, handleTimelineReset);
|
||||||
room.on(MatrixRoomEvent.Timeline, handleReactionEvent);
|
room.on(MatrixRoomEvent.Timeline, handleReactionEvent);
|
||||||
room.on(MatrixRoomEvent.Redaction, handleReactionEvent);
|
room.on(MatrixRoomEvent.Redaction, handleReactionEvent);
|
||||||
room.client.on(MatrixEventEvent.Decrypted, handleReactionEvent);
|
room.client.on(MatrixEventEvent.Decrypted, handleReactionEvent);
|
||||||
@ -306,6 +311,7 @@ export const ReactionsProvider = ({
|
|||||||
room.on(MatrixRoomEvent.LocalEchoUpdated, handleReactionEvent);
|
room.on(MatrixRoomEvent.LocalEchoUpdated, handleReactionEvent);
|
||||||
|
|
||||||
return (): void => {
|
return (): void => {
|
||||||
|
room.off(MatrixRoomEvent.TimelineReset, handleTimelineReset);
|
||||||
room.off(MatrixRoomEvent.Timeline, handleReactionEvent);
|
room.off(MatrixRoomEvent.Timeline, handleReactionEvent);
|
||||||
room.off(MatrixRoomEvent.Redaction, handleReactionEvent);
|
room.off(MatrixRoomEvent.Redaction, handleReactionEvent);
|
||||||
room.client.off(MatrixEventEvent.Decrypted, handleReactionEvent);
|
room.client.off(MatrixEventEvent.Decrypted, handleReactionEvent);
|
||||||
|
@ -9,8 +9,10 @@ import { IndexedDBStore } from "matrix-js-sdk/src/store/indexeddb";
|
|||||||
import { MemoryStore } from "matrix-js-sdk/src/store/memory";
|
import { MemoryStore } from "matrix-js-sdk/src/store/memory";
|
||||||
import {
|
import {
|
||||||
createClient,
|
createClient,
|
||||||
|
Filter,
|
||||||
ICreateClientOpts,
|
ICreateClientOpts,
|
||||||
Preset,
|
Preset,
|
||||||
|
RoomEvent,
|
||||||
Visibility,
|
Visibility,
|
||||||
} from "matrix-js-sdk/src/matrix";
|
} from "matrix-js-sdk/src/matrix";
|
||||||
import { ClientEvent } from "matrix-js-sdk/src/client";
|
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,
|
// Otherwise, a sync may complete before the listener gets applied,
|
||||||
// and we will miss it.
|
// and we will miss it.
|
||||||
const syncPromise = waitForSync(client);
|
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;
|
await syncPromise;
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
Loading…
Reference in New Issue
Block a user