mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-30 12:09:15 +00:00
feat: live-refresh stack detail container and health state (#1712)
* feat: live-refresh stack detail container and health state Keep the open stack's container cards in sync with Docker via state-invalidate events and a visibility-aware poll, without reloading compose, env, or logs. * fix: remove unused _ms parameter from visibilityInterval mock Fixes the @typescript-eslint/no-unused-vars ESLint error in CI lint job. * fix: stop stack detail live-refresh when leaving the editor Gate poll and invalidate handling on editor visibility, refresh the current selection after a mid-flight stack switch, and skip starting visibilityInterval when the tab is already hidden. * fix: avoid return in finally for stack detail live-refresh Satisfy no-unsafe-finally by gating the trailing refresh with a positive condition instead of early returns inside the finally block.
This commit is contained in:
@@ -36,6 +36,8 @@ export function visibilityInterval(fn: () => void, ms: number): () => void {
|
||||
const stop = () => { if (interval) { clearInterval(interval); interval = null; } };
|
||||
const onVisChange = () => { if (document.hidden) { stop(); } else { fn(); start(); } };
|
||||
document.addEventListener('visibilitychange', onVisChange);
|
||||
start();
|
||||
// Do not start a timer when the tab is already hidden (e.g. deep-link opened
|
||||
// in a background tab). Resume via visibilitychange when the tab is shown.
|
||||
if (!document.hidden) start();
|
||||
return () => { stop(); document.removeEventListener('visibilitychange', onVisChange); };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user