P1.9: loadDeviceSettings / loadBlacklist / saveBlacklist / saveDeviceSettings + itemToManifestEntry were duplicated across popup-only.ts and content-callable.ts. Lifts the four storage helpers into service-worker/ storage.ts and itemToManifestEntry into service-worker/vault.ts. Both router files now import from one home each. Adds storage.test.ts covering round-trips and defaults. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
/// Single home for chrome.storage.local reads/writes done by the service
|
|
/// worker. Both router files (popup-only.ts and content-callable.ts) import
|
|
/// from here — the duplicated definitions in those files were lifted out as
|
|
/// part of Plan C Phase 2 (P1.9).
|
|
|
|
import type { DeviceSettings } from '../shared/types';
|
|
import { DEFAULT_DEVICE_SETTINGS } from '../shared/types';
|
|
|
|
export async function loadDeviceSettings(): Promise<DeviceSettings> {
|
|
const r = await chrome.storage.local.get('relicarioSettings');
|
|
return (r.relicarioSettings as DeviceSettings) ?? { ...DEFAULT_DEVICE_SETTINGS };
|
|
}
|
|
|
|
export async function saveDeviceSettings(s: DeviceSettings): Promise<void> {
|
|
await chrome.storage.local.set({ relicarioSettings: s });
|
|
}
|
|
|
|
export async function loadBlacklist(): Promise<string[]> {
|
|
const r = await chrome.storage.local.get('captureBlacklist');
|
|
return (r.captureBlacklist as string[]) ?? [];
|
|
}
|
|
|
|
export async function saveBlacklist(list: string[]): Promise<void> {
|
|
await chrome.storage.local.set({ captureBlacklist: list });
|
|
}
|