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
|
// 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
|
// server that we want to receive an empty sync response after this
|
||||||
// amount of time if nothing happens.
|
// 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();
|
await _checkSyncFilter();
|
||||||
|
|
||||||
final syncRequest = sync(
|
final syncRequest = sync(
|
||||||
filter: syncFilterId,
|
filter: syncFilterId,
|
||||||
since: prevBatch,
|
since: prevBatch,
|
||||||
timeout: timeout.inMilliseconds,
|
timeout: timeout?.inMilliseconds,
|
||||||
setPresence: syncPresence,
|
setPresence: syncPresence,
|
||||||
).then((v) => Future<SyncUpdate?>.value(v)).catchError((e) {
|
).then((v) => Future<SyncUpdate?>.value(v)).catchError((e) {
|
||||||
if (e is MatrixException) {
|
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
|
// 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
|
// timeout (for initial sync) we give the server a longer time to
|
||||||
// responde.
|
// responde.
|
||||||
final responseTimeout = timeout == Duration.zero
|
final responseTimeout =
|
||||||
? const Duration(minutes: 2)
|
timeout == null ? null : timeout + const Duration(seconds: 10);
|
||||||
: 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));
|
onSyncStatus.add(SyncStatusUpdate(SyncStatus.processing));
|
||||||
if (syncResp == null) throw syncError ?? 'Unknown sync error';
|
if (syncResp == null) throw syncError ?? 'Unknown sync error';
|
||||||
if (_currentSyncId != syncRequest.hashCode) {
|
if (_currentSyncId != syncRequest.hashCode) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue