Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Haze <hazeone@users.noreply.github.com> Co-authored-by: paisley <8197966+su8su@users.noreply.github.com> Co-authored-by: Felix <24791380+vcfgv@users.noreply.github.com>
31 lines
723 B
TypeScript
31 lines
723 B
TypeScript
export interface QuitLifecycleState {
|
|
cleanupStarted: boolean;
|
|
cleanupCompleted: boolean;
|
|
}
|
|
|
|
export type QuitLifecycleAction = 'start-cleanup' | 'cleanup-in-progress' | 'allow-quit';
|
|
|
|
export function createQuitLifecycleState(): QuitLifecycleState {
|
|
return {
|
|
cleanupStarted: false,
|
|
cleanupCompleted: false,
|
|
};
|
|
}
|
|
|
|
export function requestQuitLifecycleAction(state: QuitLifecycleState): QuitLifecycleAction {
|
|
if (state.cleanupCompleted) {
|
|
return 'allow-quit';
|
|
}
|
|
|
|
if (state.cleanupStarted) {
|
|
return 'cleanup-in-progress';
|
|
}
|
|
|
|
state.cleanupStarted = true;
|
|
return 'start-cleanup';
|
|
}
|
|
|
|
export function markQuitCleanupCompleted(state: QuitLifecycleState): void {
|
|
state.cleanupCompleted = true;
|
|
}
|