refactor: Do not set default timeout for initialSync
This commit is contained in:
parent
c0dc8ca0eb
commit
812c7dde82
|
|
@ -2283,16 +2283,18 @@ class Client extends MatrixApi {
|
|||
// The timeout we send to the server for the sync loop. It says to the
|
||||
// server that we want to receive an empty sync response after this
|
||||
// amount of time if nothing happens.
|
||||
timeout ??= const Duration(seconds: 30);
|
||||
if (prevBatch != null) timeout ??= const Duration(seconds: 30);
|
||||
|
||||
await ensureNotSoftLoggedOut(timeout * 2);
|
||||
await ensureNotSoftLoggedOut(
|
||||
timeout == null ? const Duration(minutes: 1) : (timeout * 2),
|
||||
);
|
||||
|
||||
await _checkSyncFilter();
|
||||
|
||||
final syncRequest = sync(
|
||||
filter: syncFilterId,
|
||||
since: prevBatch,
|
||||
timeout: timeout.inMilliseconds,
|
||||
timeout: timeout?.inMilliseconds,
|
||||
setPresence: syncPresence,
|
||||
).then((v) => Future<SyncUpdate?>.value(v)).catchError((e) {
|
||||
if (e is MatrixException) {
|
||||
|
|
@ -2308,11 +2310,13 @@ class Client extends MatrixApi {
|
|||
// The timeout for the response from the server. If we do not set a sync
|
||||
// timeout (for initial sync) we give the server a longer time to
|
||||
// responde.
|
||||
final responseTimeout = timeout == Duration.zero
|
||||
? const Duration(minutes: 2)
|
||||
: timeout + const Duration(seconds: 10);
|
||||
final responseTimeout =
|
||||
timeout == null ? null : timeout + const Duration(seconds: 10);
|
||||
|
||||
final syncResp = responseTimeout == null
|
||||
? await syncRequest
|
||||
: await syncRequest.timeout(responseTimeout);
|
||||
|
||||
final syncResp = await syncRequest.timeout(responseTimeout);
|
||||
onSyncStatus.add(SyncStatusUpdate(SyncStatus.processing));
|
||||
if (syncResp == null) throw syncError ?? 'Unknown sync error';
|
||||
if (_currentSyncId != syncRequest.hashCode) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue