feat(ext/popup): fetch vault_settings on unlock; add to PopupState
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/// Popup entry point — state machine with view routing.
|
/// Popup entry point — state machine with view routing.
|
||||||
///
|
///
|
||||||
/// Views: setup | locked | list | detail | add | edit
|
/// Views: setup | locked | list | detail | add | edit | settings | settings-vault
|
||||||
/// Navigation works by updating `currentState` and calling `render()`.
|
/// Navigation works by updating `currentState` and calling `render()`.
|
||||||
|
|
||||||
import type { Request, Response } from '../shared/messages';
|
import type { Request, Response } from '../shared/messages';
|
||||||
@@ -23,7 +23,7 @@ export function escapeHtml(str: string): string {
|
|||||||
|
|
||||||
// --- State ---
|
// --- State ---
|
||||||
|
|
||||||
export type View = 'locked' | 'list' | 'detail' | 'add' | 'edit' | 'settings';
|
export type View = 'locked' | 'list' | 'detail' | 'add' | 'edit' | 'settings' | 'settings-vault';
|
||||||
|
|
||||||
export interface PopupState {
|
export interface PopupState {
|
||||||
view: View;
|
view: View;
|
||||||
@@ -42,6 +42,8 @@ export interface PopupState {
|
|||||||
capturedTabId: number | null;
|
capturedTabId: number | null;
|
||||||
capturedUrl: string;
|
capturedUrl: string;
|
||||||
newType: import('../shared/types').ItemType | null;
|
newType: import('../shared/types').ItemType | null;
|
||||||
|
vaultSettings: import('../shared/types').VaultSettings | null;
|
||||||
|
generatorDefaults: import('../shared/types').GeneratorRequest | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentState: PopupState = {
|
let currentState: PopupState = {
|
||||||
@@ -57,6 +59,8 @@ let currentState: PopupState = {
|
|||||||
capturedTabId: null,
|
capturedTabId: null,
|
||||||
capturedUrl: '',
|
capturedUrl: '',
|
||||||
newType: null,
|
newType: null,
|
||||||
|
vaultSettings: null,
|
||||||
|
generatorDefaults: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getState(): PopupState {
|
export function getState(): PopupState {
|
||||||
@@ -175,6 +179,16 @@ async function init(): Promise<void> {
|
|||||||
const listResp = await sendMessage({ type: 'list_items' });
|
const listResp = await sendMessage({ type: 'list_items' });
|
||||||
if (listResp.ok) {
|
if (listResp.ok) {
|
||||||
const listData = listResp.data as { items: Array<[ItemId, ManifestEntry]> };
|
const listData = listResp.data as { items: Array<[ItemId, ManifestEntry]> };
|
||||||
|
// Fetch vault settings so subsequent screens (generator popover,
|
||||||
|
// settings-vault) can show current values without a round-trip.
|
||||||
|
// Failures swallow silently — list view still renders; consumers
|
||||||
|
// can show "settings not loaded" if needed.
|
||||||
|
const vsResp = await sendMessage({ type: 'get_vault_settings' });
|
||||||
|
if (vsResp.ok) {
|
||||||
|
const vs = (vsResp.data as { settings: import('../shared/types').VaultSettings }).settings;
|
||||||
|
currentState.vaultSettings = vs;
|
||||||
|
currentState.generatorDefaults = vs.generator_defaults;
|
||||||
|
}
|
||||||
navigate('list', { entries: listData.items });
|
navigate('list', { entries: listData.items });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user