story-research-zapwall/lib/articleQueries.ts
2026-01-07 01:51:26 +01:00

15 lines
588 B
TypeScript

import type { Article } from '@/types/nostr'
import { objectCache } from './objectCache'
export async function getArticlesBySeries(seriesId: string, _timeoutMs: number = 5000, _limit: number = 100): Promise<Article[]> {
// Read only from IndexedDB cache
const allPublications = await objectCache.getAll('publication')
const articles = allPublications as Article[]
// Filter by seriesId
const seriesArticles = articles.filter((article) => article.seriesId === seriesId)
// Sort by creation date descending
return seriesArticles.sort((a, b) => b.createdAt - a.createdAt)
}