From a113bc13e569049c59baa2165d28a992d7bdde7b Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sun, 15 Feb 2026 18:05:38 -0800 Subject: Vanilla JS (v3): Final parity with React (Search, Settings, Shortcuts) --- frontend-vanilla/src/store.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'frontend-vanilla/src/store.ts') diff --git a/frontend-vanilla/src/store.ts b/frontend-vanilla/src/store.ts index c978fd2..a7a99b0 100644 --- a/frontend-vanilla/src/store.ts +++ b/frontend-vanilla/src/store.ts @@ -1,6 +1,6 @@ import type { Feed, Item, Category } from './types.ts'; -export type StoreEvent = 'feeds-updated' | 'tags-updated' | 'items-updated' | 'active-feed-updated' | 'active-tag-updated' | 'loading-state-changed' | 'filter-updated'; +export type StoreEvent = 'feeds-updated' | 'tags-updated' | 'items-updated' | 'active-feed-updated' | 'active-tag-updated' | 'loading-state-changed' | 'filter-updated' | 'search-updated' | 'theme-updated'; export type FilterType = 'unread' | 'all' | 'starred'; @@ -11,8 +11,11 @@ export class Store extends EventTarget { activeFeedId: number | null = null; activeTagName: string | null = null; filter: FilterType = 'unread'; + searchQuery: string = ''; loading: boolean = false; hasMore: boolean = true; + theme: string = localStorage.getItem('neko-theme') || 'light'; + fontTheme: string = localStorage.getItem('neko-font-theme') || 'default'; setFeeds(feeds: Feed[]) { this.feeds = feeds; @@ -52,6 +55,13 @@ export class Store extends EventTarget { } } + setSearchQuery(query: string) { + if (this.searchQuery !== query) { + this.searchQuery = query; + this.emit('search-updated'); + } + } + setLoading(loading: boolean) { this.loading = loading; this.emit('loading-state-changed'); @@ -61,6 +71,18 @@ export class Store extends EventTarget { this.hasMore = hasMore; } + setTheme(theme: string) { + this.theme = theme; + localStorage.setItem('neko-theme', theme); + this.emit('theme-updated'); + } + + setFontTheme(fontTheme: string) { + this.fontTheme = fontTheme; + localStorage.setItem('neko-font-theme', fontTheme); + this.emit('theme-updated'); + } + private emit(type: StoreEvent, detail?: any) { this.dispatchEvent(new CustomEvent(type, { detail })); } -- cgit v1.2.3