mirror of
https://github.com/stablyai/orca.git
synced 2026-09-24 00:02:24 +00:00
fix(renderer): dispose activity pagehide listener on HMR
This commit is contained in:
@@ -74,10 +74,22 @@ export function flushPendingClearCompletedEvictions(): void {
|
||||
evict()
|
||||
}
|
||||
}
|
||||
export function disposePendingClearCompletedEvictionListener(): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.removeEventListener('pagehide', flushPendingClearCompletedEvictions)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('pagehide', flushPendingClearCompletedEvictions)
|
||||
}
|
||||
|
||||
if (import.meta !== undefined && import.meta.hot) {
|
||||
// Vite can replace this module without a full renderer reload. Remove the
|
||||
// pagehide hook so dev sessions do not retain stale eviction closures.
|
||||
import.meta.hot.dispose(disposePendingClearCompletedEvictionListener)
|
||||
}
|
||||
|
||||
// Why a fallback: sonner only fires onDismiss/onAutoClose for the toast's own close paths; a
|
||||
// `toast.dismiss()` from another caller leaves the eviction pending until pagehide.
|
||||
export const CLEAR_COMPLETED_EVICTION_FALLBACK_MS = 60_000
|
||||
|
||||
Reference in New Issue
Block a user