@samitouri / QOSami-HFS / commits / fc7fa43f

fix: no new dialog/menu was opening after closing show-file using plugin show-any detail: browser history state was inconsistent after closing the modal, leaving waitClosing pending forever

fix: no new dialog/menu was opening after closing show-file using plugin show-any detail: browser history state was inconsistent after closing the modal, leaving waitClosing pending forever

Massimo Melina committed Dec 31, 2025 at 17:41 UTC fc7fa43fca76b4b3283234e359cab5f76ee95269
1 file changed +8 -4
shared/dialogs.ts
+8 -4
@@ -78,10 +78,14 @@ let ignorePopState = false
78 async function back() {
79 ignorePopState = true
80 let was = history.state
81 - history.back()
82 - return waitClosing = waitClosing.then(() => new Promise<void>(res => {
83 - const h = setInterval(() => was !== history.state && res() , 10)
84 - setTimeout(() => clearTimeout(h), 500)
81 + return waitClosing = waitClosing.then(() => new Promise<void>(async res => {
82 + const started = Date.now()
83 + while (was === history.state) { // history.back seems to not always be effective, so we loop for it
84 + if (Date.now() - started > 1000) break // emergency brake
85 + history.back()
86 + await wait(10)
87 + }
88 + res()
89 }))
90 }
91