replace localStorage with pglite for persistent data, force-add previously ignored lib/ files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 14:05:40 +01:00
parent 3cdcfb7266
commit c96c24a250
31 changed files with 1552 additions and 162 deletions
+33
View File
@@ -0,0 +1,33 @@
import { clearCachedFeed, loadCachedFeed, saveCachedFeed } from "@/shared/db/feed-cache-db"
import type { PGlite } from "@electric-sql/pglite"
import type { FeedItem } from "./assemble-feed"
export interface FeedCacheData {
items: FeedItem[]
updatedAt: number
}
export async function loadFeedCache(db: PGlite): Promise<FeedCacheData | null> {
return loadCachedFeed(db)
}
export async function saveFeedCache(db: PGlite, items: FeedItem[]): Promise<void> {
await saveCachedFeed(db, items)
}
export async function clearFeedCache(db: PGlite): Promise<void> {
await clearCachedFeed(db)
}
export function mergeFeedItems(cached: FeedItem[], fresh: FeedItem[]): FeedItem[] {
const map = new Map<string, FeedItem>()
for (const item of cached) map.set(item.id, item)
for (const item of fresh) map.set(item.id, item)
return Array.from(map.values()).sort((a, b) => {
if (a.date && b.date) return b.date.localeCompare(a.date)
if (!a.date && b.date) return 1
if (a.date && !b.date) return -1
return a.title.localeCompare(b.title)
})
}