feat(frontend): add configurable app settings (file load limit, tag rule apply_to_existing)
- Add appSettings store (localStorage-backed) with two settings: fileLoadLimit (default 100) and tagRuleApplyToExisting (default false) - Settings page: new Behaviour section with numeric input for files per page (10–500) and an on/off toggle for retroactive tag rule application - files/+page.svelte: derive LIMIT from appSettings.fileLoadLimit so changes take effect immediately without reload - TagRuleEditor: pass apply_to_existing from appSettings when activating a rule via PATCH (only sent on activation, not deactivation) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
export interface AppSettings {
|
||||
fileLoadLimit: number;
|
||||
tagRuleApplyToExisting: boolean;
|
||||
}
|
||||
|
||||
const DEFAULTS: AppSettings = {
|
||||
fileLoadLimit: 100,
|
||||
tagRuleApplyToExisting: false,
|
||||
};
|
||||
|
||||
function load(): AppSettings {
|
||||
if (!browser) return { ...DEFAULTS };
|
||||
try {
|
||||
const stored = JSON.parse(localStorage.getItem('app-settings') ?? 'null');
|
||||
return stored ? { ...DEFAULTS, ...stored } : { ...DEFAULTS };
|
||||
} catch {
|
||||
return { ...DEFAULTS };
|
||||
}
|
||||
}
|
||||
|
||||
export const appSettings = writable<AppSettings>(load());
|
||||
|
||||
appSettings.subscribe((v) => {
|
||||
if (browser) localStorage.setItem('app-settings', JSON.stringify(v));
|
||||
});
|
||||
Reference in New Issue
Block a user