/** * Reactive settings store for vault security preferences. * * Settings are persisted in IndexedDB (meta store) so they survive * page reloads. Defaults are used until the user explicitly saves. */ import { getSetting, saveSetting } from '../storage/db.js' export class SettingsStore { autoLockMinutes = $state(5) lockOnTabSwitch = $state(true) /** * Load persisted settings from IndexedDB. * Falls back to defaults for any missing keys. */ async load() { const minutes = await getSetting('autoLockMinutes') const tabSwitch = await getSetting('lockOnTabSwitch') this.autoLockMinutes = minutes != null ? Number(minutes) : 5 this.lockOnTabSwitch = tabSwitch != null ? Boolean(tabSwitch) : true } /** * Persist current settings to IndexedDB. */ async save() { await saveSetting('autoLockMinutes', this.autoLockMinutes) await saveSetting('lockOnTabSwitch', this.lockOnTabSwitch) } } export const settings = new SettingsStore()