Files
boris/src/services/meCache.ts
Gigi 11c7564f8c feat: split Reads tab into Reads and Links
- Reads: Only Nostr-native articles (kind:30023)
- Links: Only external URLs with reading progress
- Create linksService.ts for fetching external URL links
- Update readsService to filter only Nostr articles
- Add Links tab between Reads and Writings with same filtering
- Add /me/links route
- Update meCache to include links field
- Both tabs support reading progress filters
- Lazy loading for both tabs

This provides clear separation between native Nostr content and external web links.
2025-10-16 01:33:04 +02:00

58 lines
1.4 KiB
TypeScript

import { Highlight } from '../types/highlights'
import { Bookmark } from '../types/bookmarks'
import { ReadItem } from './readsService'
export interface MeCache {
highlights: Highlight[]
bookmarks: Bookmark[]
reads: ReadItem[]
links: ReadItem[]
timestamp: number
}
const meCache = new Map<string, MeCache>() // key: pubkey
export function getCachedMeData(pubkey: string): MeCache | null {
const entry = meCache.get(pubkey)
if (!entry) return null
return entry
}
export function setCachedMeData(
pubkey: string,
highlights: Highlight[],
bookmarks: Bookmark[],
reads: ReadItem[],
links: ReadItem[] = []
): void {
meCache.set(pubkey, {
highlights,
bookmarks,
reads,
links,
timestamp: Date.now()
})
}
export function updateCachedHighlights(pubkey: string, highlights: Highlight[]): void {
const existing = meCache.get(pubkey)
if (existing) {
meCache.set(pubkey, { ...existing, highlights, timestamp: Date.now() })
}
}
export function updateCachedBookmarks(pubkey: string, bookmarks: Bookmark[]): void {
const existing = meCache.get(pubkey)
if (existing) {
meCache.set(pubkey, { ...existing, bookmarks, timestamp: Date.now() })
}
}
export function updateCachedReads(pubkey: string, reads: ReadItem[]): void {
const existing = meCache.get(pubkey)
if (existing) {
meCache.set(pubkey, { ...existing, reads, timestamp: Date.now() })
}
}