종료 보완: DB 를 닫은 뒤 온 변환 성공 응답도 버림 · 트레이와 갱신 타이머를 TrayShell 로 묶어 종료 · 없어진 트레이 처리 회귀 시험
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
31
app/src/main/tray-shell.ts
Normal file
31
app/src/main/tray-shell.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/** 트레이 아이콘과 그 갱신 타이머. 종료할 때 타이머를 먼저 멈추고 트레이를 없앤다 (v1.8.2: 'Tray is destroyed' 오류 창) */
|
||||
export interface TrayLike {
|
||||
isDestroyed(): boolean;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export class TrayShell<T extends TrayLike> {
|
||||
private tray: T | null = null;
|
||||
private timers: NodeJS.Timeout[] = [];
|
||||
|
||||
set(tray: T): void {
|
||||
this.tray = tray;
|
||||
}
|
||||
|
||||
/** 쓸 수 있는 트레이 (없거나, 종료했거나, Windows 로그오프 등으로 Electron 이 먼저 없앴으면 null) */
|
||||
get(): T | null {
|
||||
return this.tray && !this.tray.isDestroyed() ? this.tray : null;
|
||||
}
|
||||
|
||||
every(ms: number, fn: () => void): void {
|
||||
this.timers.push(setInterval(fn, ms));
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
for (const t of this.timers) clearInterval(t);
|
||||
this.timers = [];
|
||||
const tray = this.get();
|
||||
this.tray = null;
|
||||
tray?.destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user