From b38dbe06a615f1d9230e6c5528270e0075fc63a9 Mon Sep 17 00:00:00 2001 From: joenunezb Date: Fri, 26 Dec 2025 19:01:05 -0800 Subject: [PATCH 1/2] fix: Properly handle promises that lead to hangs on swipes --- src/systems/features/chapterCheckpoint.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/systems/features/chapterCheckpoint.js b/src/systems/features/chapterCheckpoint.js index 0f8d24c..c9f5362 100644 --- a/src/systems/features/chapterCheckpoint.js +++ b/src/systems/features/chapterCheckpoint.js @@ -14,6 +14,7 @@ let currentlyHiddenRange = null; // Debounce restore to prevent loops let isRestoring = false; let restoreTimeout = null; +let pendingResolve = null; // Track pending promise resolve function /** * Gets the current chapter checkpoint message ID for the active chat @@ -129,13 +130,19 @@ export async function restoreCheckpointOnLoad() { return; } - // Clear any pending timeout + // Clear any pending timeout and resolve the pending promise if (restoreTimeout) { clearTimeout(restoreTimeout); + restoreTimeout = null; + } + if (pendingResolve) { + pendingResolve(); + pendingResolve = null; } // Debounce: wait 100ms before actually restoring return new Promise((resolve) => { + pendingResolve = resolve; // Track this promise's resolve function restoreTimeout = setTimeout(async () => { isRestoring = true; try { @@ -174,6 +181,7 @@ export async function restoreCheckpointOnLoad() { } } finally { isRestoring = false; + pendingResolve = null; resolve(); } }, 100); From afa39b13879d88c0be7d777ddae05f00fb36ce25 Mon Sep 17 00:00:00 2001 From: joenunezb Date: Fri, 26 Dec 2025 19:24:08 -0800 Subject: [PATCH 2/2] Useless comments --- src/systems/features/chapterCheckpoint.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/systems/features/chapterCheckpoint.js b/src/systems/features/chapterCheckpoint.js index c9f5362..5ac2c41 100644 --- a/src/systems/features/chapterCheckpoint.js +++ b/src/systems/features/chapterCheckpoint.js @@ -14,7 +14,7 @@ let currentlyHiddenRange = null; // Debounce restore to prevent loops let isRestoring = false; let restoreTimeout = null; -let pendingResolve = null; // Track pending promise resolve function +let pendingResolve = null; /** * Gets the current chapter checkpoint message ID for the active chat @@ -142,7 +142,7 @@ export async function restoreCheckpointOnLoad() { // Debounce: wait 100ms before actually restoring return new Promise((resolve) => { - pendingResolve = resolve; // Track this promise's resolve function + pendingResolve = resolve; restoreTimeout = setTimeout(async () => { isRestoring = true; try {