refactor(ext/popup): extract teardownSettingsCommon (Plan C Phase 5)
DEV-C P2: settings.ts:56-65 and settings-vault.ts:15-22 had near- identical cleanup paths. Single source for closeGeneratorPanel + activeKeyHandler removal. Helper takes the handler as a parameter and returns null so each caller still owns its own module-scoped handler state. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import type {
|
||||
import type { SessionTimeoutConfig } from '../../shared/messages';
|
||||
import { relativeTime } from '../../shared/relative-time';
|
||||
import { openGeneratorPanel, closeGeneratorPanel, isGeneratorPanelOpen } from './generator-panel';
|
||||
import { teardownSettingsCommon } from './settings';
|
||||
import { GLYPH_NEXT } from '../../shared/glyphs';
|
||||
|
||||
let pendingSettings: VaultSettings | null = null;
|
||||
@@ -17,11 +18,7 @@ let pendingSession: SessionTimeoutConfig | null = null;
|
||||
let baseSession: SessionTimeoutConfig | null = null;
|
||||
|
||||
export function teardown(): void {
|
||||
closeGeneratorPanel();
|
||||
if (activeKeyHandler) {
|
||||
document.removeEventListener('keydown', activeKeyHandler);
|
||||
activeKeyHandler = null;
|
||||
}
|
||||
activeKeyHandler = teardownSettingsCommon(activeKeyHandler);
|
||||
pendingSettings = null;
|
||||
pendingSession = null;
|
||||
baseSession = null;
|
||||
|
||||
Reference in New Issue
Block a user