diff --git a/src/desktop-files/settings-tab.ts b/src/desktop-files/settings-tab.ts index 10ef84e99..740c2f2bd 100644 --- a/src/desktop-files/settings-tab.ts +++ b/src/desktop-files/settings-tab.ts @@ -16,12 +16,15 @@ import { getUserAssociations, resolveOpener, setUserAssociations, + subscribeOpeners, } from './openers'; import { getTypes } from './registry'; // Pre-registered globally by the lazy shell-overlays bundle (Stage 10) — see src/shell-overlays/entry.ts. const TAB_ID = 'os-file-associations'; +let unsubscribe: ( () => void ) | null = null; + /** * Register the tab. Called once at bundle boot from * `src/desktop-files/index.ts`. @@ -32,7 +35,21 @@ export function registerFileAssociationsTab(): void { label: 'File Associations', order: 50, render( body ) { + if ( unsubscribe ) { + unsubscribe(); + unsubscribe = null; + } renderTab( body ); + unsubscribe = subscribeOpeners( () => { + if ( ! body.isConnected ) { + if ( unsubscribe ) { + unsubscribe(); + unsubscribe = null; + } + return; + } + renderTab( body ); + } ); }, } ); }