From 60a92cf6b72e0dd0776ded2529d72666383500b5 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Thu, 28 Oct 2021 12:14:58 +0530 Subject: [PATCH] Limit recursion Signed-off-by: RMidhunSuresh --- src/domain/session/room/timeline/TimelineViewModel.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/domain/session/room/timeline/TimelineViewModel.js b/src/domain/session/room/timeline/TimelineViewModel.js index 2f47ed77..e7762205 100644 --- a/src/domain/session/room/timeline/TimelineViewModel.js +++ b/src/domain/session/room/timeline/TimelineViewModel.js @@ -49,7 +49,11 @@ export class TimelineViewModel extends ViewModel { this._showJumpDown = false; } - async watchForGapFill(gapPromise, gapTile) { + async watchForGapFill(gapPromise, gapTile, depth = 0) { + if (depth >= 10) { + console.error("watchForGapFill exceeded a recursive depth of 10"); + return; + } let hasSeenUpdate = false; const checkForUpdate = (idx, tile) => { if (tile.shape !== "gap") { @@ -85,7 +89,7 @@ export class TimelineViewModel extends ViewModel { return; } if (!hasSeenUpdate) { - this.watchForGapFill(gapTile.notifyVisible(), gapTile); + this.watchForGapFill(gapTile.notifyVisible(), gapTile, depth + 1); } }