diff --git a/docs/changelog.md b/docs/changelog.md index afba5bbb..47a2bdbb 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -16,6 +16,8 @@ _Release date: 19th Sep, 2024_ - **IMPROVE**: Redesigned the Focus Selector UI. Now it's more intuitive for new users. - **IMPROVE**: Significantly reduce the chance of being stuck in infinite message generating state. +- **FIX**: Fixed minor bugs. + ## v0.0.2.0 _Release date: 15th Sep, 2024_ diff --git a/src/content-script/main-world/router.ts b/src/content-script/main-world/router.ts index 6bceb5ef..9d80990b 100644 --- a/src/content-script/main-world/router.ts +++ b/src/content-script/main-world/router.ts @@ -6,7 +6,7 @@ import { RouterEvent } from "@/types/ws.types"; import { DomSelectors } from "@/utils/DomSelectors"; import { mainWorldExec } from "@/utils/hof"; import UiUtils from "@/utils/UiUtils"; -import { whereAmI } from "@/utils/utils"; +import { sleep, whereAmI } from "@/utils/utils"; type NextRouter = typeof window.next; @@ -135,12 +135,13 @@ class Router { private async waitForRouteChangeComplete( location: ReturnType, ) { + await sleep(1000); + return new Promise((resolve) => { const conditions: Partial boolean>> = { thread: () => { try { - if (UiUtils.getMessageBlocks(true).length < 1) return false; - return true; + return UiUtils.getMessageBlocks(true).length >= 1; } catch { return false; } @@ -156,7 +157,9 @@ class Router { const interval = setInterval(() => { if (condition()) { + console.log("condition met"); clearInterval(interval); + return resolve(); } }, 100);