From b1fd5f1ad530a2d1f3eb38cfa4f13aa073a31ea3 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Thu, 4 Aug 2022 16:33:59 +0530 Subject: [PATCH] Do not fill gap when offline --- src/domain/session/room/timeline/tiles/GapTile.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/domain/session/room/timeline/tiles/GapTile.js b/src/domain/session/room/timeline/tiles/GapTile.js index 6caa4b9b..e2e5b041 100644 --- a/src/domain/session/room/timeline/tiles/GapTile.js +++ b/src/domain/session/room/timeline/tiles/GapTile.js @@ -16,6 +16,8 @@ limitations under the License. import {SimpleTile} from "./SimpleTile.js"; import {UpdateAction} from "../UpdateAction.js"; +import {ConnectionError} from "../../../../../matrix/error.js"; +import {ConnectionStatus} from "../../../../../matrix/net/Reconnector"; export class GapTile extends SimpleTile { constructor(entry, options) { @@ -29,6 +31,7 @@ export class GapTile extends SimpleTile { async fill() { if (!this._loading && !this._entry.edgeReached) { this._loading = true; + this._error = null; this.emitChange("isLoading"); try { await this._room.fillGap(this._entry, 10); @@ -55,7 +58,15 @@ export class GapTile extends SimpleTile { let canFillMore; this._siblingChanged = false; do { - canFillMore = await this.fill(); + try { + canFillMore = await this.fill(); + } + catch (e) { + if (e instanceof ConnectionError) { + await this.options.client.reconnector.connectionStatus.waitFor(status => status === ConnectionStatus.Online).promise; + canFillMore = true; + } + } depth = depth + 1; } while (depth < 10 && !this._siblingChanged && canFillMore && !this.isDisposed); }