import type { ReviewTip } from '@/types/nostr' import { objectCache } from './objectCache' import { getCachedObjectById } from './helpers/queryHelpers' export async function getReviewTipById(reviewTipId: string, _timeoutMs: number = 5000): Promise { return await getCachedObjectById('review_tip', reviewTipId) } export async function getReviewTipsForArticle(articleId: string, _timeoutMs: number = 5000): Promise { // Read only from IndexedDB cache const allReviewTips = await objectCache.getAll('review_tip') const reviewTips = allReviewTips as ReviewTip[] // Filter by articleId const articleReviewTips = reviewTips.filter((tip) => tip.articleId === articleId) // Sort by creation date descending return articleReviewTips.sort((a, b) => b.createdAt - a.createdAt) } export async function getReviewTipsForReview(reviewId: string, _timeoutMs: number = 5000): Promise { // Read only from IndexedDB cache const allReviewTips = await objectCache.getAll('review_tip') const reviewTips = allReviewTips as ReviewTip[] // Filter by reviewId const reviewReviewTips = reviewTips.filter((tip) => tip.reviewId === reviewId) // Sort by creation date descending return reviewReviewTips.sort((a, b) => b.createdAt - a.createdAt) }