@@ -9,8 +9,10 @@ import { IndexedDBStore } from "matrix-js-sdk/src/store/indexeddb";
9
9
import { MemoryStore } from "matrix-js-sdk/src/store/memory" ;
10
10
import {
11
11
createClient ,
12
+ Filter ,
12
13
ICreateClientOpts ,
13
14
Preset ,
15
+ RoomEvent ,
14
16
Visibility ,
15
17
} from "matrix-js-sdk/src/matrix" ;
16
18
import { ClientEvent } from "matrix-js-sdk/src/client" ;
@@ -126,6 +128,10 @@ export async function initClient(
126
128
store : new MemoryStore ( ) ,
127
129
} ) ;
128
130
131
+ client . on ( RoomEvent . TimelineReset , ( ) => {
132
+ logger . warn ( "Received TimelineReset indicating limited sync response" ) ;
133
+ } ) ;
134
+
129
135
// In case of logging in a new matrix account but there is still crypto local store. This is needed for:
130
136
// - We lost the auth tokens and cannot restore the client resulting in registering a new user.
131
137
// - We start the sign in flow but are registered with a guest user. (It should additionally log out the guest before)
@@ -165,7 +171,20 @@ export async function initClient(
165
171
// Otherwise, a sync may complete before the listener gets applied,
166
172
// and we will miss it.
167
173
const syncPromise = waitForSync ( client ) ;
168
- await client . startClient ( { clientWellKnownPollPeriod : 60 * 10 } ) ;
174
+ await client . startClient ( {
175
+ clientWellKnownPollPeriod : 60 * 10 ,
176
+ // TODO: ask for a high limit to avoid gappy syncs
177
+ filter : Filter . fromJson ( undefined , "element-call" , {
178
+ room : {
179
+ timeline : {
180
+ limit : 1 ,
181
+ } ,
182
+ } ,
183
+ } ) ,
184
+ // we only ask for 1 past message as we really only care about future messages
185
+ // n.b. past reactions are then not visible
186
+ initialSyncLimit : 1 ,
187
+ } ) ;
169
188
await syncPromise ;
170
189
171
190
return client ;
0 commit comments