2026-01-07 01:51:26 +01:00

15 lines
549 B
TypeScript

import type { Review } from '@/types/nostr'
import { objectCache } from './objectCache'
export async function getReviewsForArticle(articleId: string, _timeoutMs: number = 5000): Promise<Review[]> {
// Read only from IndexedDB cache
const allReviews = await objectCache.getAll('review')
const reviews = allReviews as Review[]
// Filter by articleId
const articleReviews = reviews.filter((review) => review.articleId === articleId)
// Sort by creation date descending
return articleReviews.sort((a, b) => b.createdAt - a.createdAt)
}