mirror of
https://github.com/dergigi/boris.git
synced 2025-12-24 01:54:19 +01:00
- 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.
58 lines
1.4 KiB
TypeScript
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() })
|
|
}
|
|
}
|
|
|