| 1 | const STORAGE_KEY = "t3code:snap-shot-setup-resume:v1"; |
| 2 | let startupChecked = false; |
| 3 | |
| 4 | export 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; |
| 12 | } |
| 13 | |
| 14 | export 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 | } |
| 20 | } |
| 21 | |
| 22 | export function clearSnapShotSetupResume(): void { |
| 23 | try { |
| 24 | window.localStorage.removeItem(STORAGE_KEY); |
| 25 | } catch { |
| 26 | // Storage may be unavailable. |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // Check once per renderer startup so opening System Settings does not redirect |
| 31 | // subsequent navigation in the current session. |
| 32 | export function shouldResumeSnapShotSetupOnStartup(): boolean { |
| 33 | if (startupChecked) return false; |
| 34 | startupChecked = true; |
| 35 | return readSnapShotSetupResume() !== null; |
| 36 | } |