fix(tui): track all timeouts in Footer to prevent memory leak (#8255)
This commit is contained in:
parent
86900d71f5
commit
8917dfdf5e
1 changed files with 7 additions and 4 deletions
|
|
@ -25,24 +25,27 @@ export function Footer() {
|
||||||
})
|
})
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
// Track all timeouts to ensure proper cleanup
|
||||||
|
const timeouts: ReturnType<typeof setTimeout>[] = []
|
||||||
|
|
||||||
function tick() {
|
function tick() {
|
||||||
if (connected()) return
|
if (connected()) return
|
||||||
if (!store.welcome) {
|
if (!store.welcome) {
|
||||||
setStore("welcome", true)
|
setStore("welcome", true)
|
||||||
timeout = setTimeout(() => tick(), 5000)
|
timeouts.push(setTimeout(() => tick(), 5000))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (store.welcome) {
|
if (store.welcome) {
|
||||||
setStore("welcome", false)
|
setStore("welcome", false)
|
||||||
timeout = setTimeout(() => tick(), 10_000)
|
timeouts.push(setTimeout(() => tick(), 10_000))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let timeout = setTimeout(() => tick(), 10_000)
|
timeouts.push(setTimeout(() => tick(), 10_000))
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
clearTimeout(timeout)
|
timeouts.forEach(clearTimeout)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue