Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

snapShotSetupResume.ts

36 lines1.1 KB

1const STORAGE_KEY = "t3code:snap-shot-setup-resume:v1";
2let startupChecked = false;
3​
4export function readSnapShotSetupResume(): { wasEnabled: boolean } | null {
5 try {
6 const value = window.localStorage.getItem(STORAGE_KEY);
7 if (value === "enabled" || value === "disabled") return { wasEnabled: value === "enabled" };
8 } catch {
9 // Permission setup still works when local storage is unavailable.
10 }
11 return null;
13​
14export function saveSnapShotSetupResume(wasEnabled: boolean): void {
15 try {
16 window.localStorage.setItem(STORAGE_KEY, wasEnabled ? "enabled" : "disabled");
17 } catch {
18 // Permission setup still works when local storage is unavailable.
19 }
21​
22export function clearSnapShotSetupResume(): void {
23 try {
24 window.localStorage.removeItem(STORAGE_KEY);
25 } catch {
26 // Storage may be unavailable.
27 }
29​
30// Check once per renderer startup so opening System Settings does not redirect
31// subsequent navigation in the current session.
32export function shouldResumeSnapShotSetupOnStartup(): boolean {
33 if (startupChecked) return false;
34 startupChecked = true;
35 return readSnapShotSetupResume() !== null;