mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 22:54:30 +01:00
feat: add relay rebroadcast settings for caching and propagation
- Add two new settings: - Use local relay(s) as cache (default: enabled) - Rebroadcast events to all relays (default: disabled) - Create rebroadcastService to handle rebroadcasting events - Hook into article, bookmark, and highlight fetching services - Automatically rebroadcast fetched events based on settings: - Articles when opened - Bookmarks when fetched - Highlights when fetched - Add RelayRebroadcastSettings component with plane/globe icons - Benefits: - Local caching for offline access - Content propagation across nostr network - User control over bandwidth usage
This commit is contained in:
@@ -5,6 +5,7 @@ import { fetchHighlightsForArticle } from '../services/highlightService'
|
||||
import { ReadableContent } from '../services/readerService'
|
||||
import { Highlight } from '../types/highlights'
|
||||
import { NostrEvent } from 'nostr-tools'
|
||||
import { UserSettings } from '../services/settingsService'
|
||||
|
||||
interface UseArticleLoaderProps {
|
||||
naddr: string | undefined
|
||||
@@ -18,6 +19,7 @@ interface UseArticleLoaderProps {
|
||||
setCurrentArticleCoordinate: (coord: string | undefined) => void
|
||||
setCurrentArticleEventId: (id: string | undefined) => void
|
||||
setCurrentArticle?: (article: NostrEvent) => void
|
||||
settings?: UserSettings
|
||||
}
|
||||
|
||||
export function useArticleLoader({
|
||||
@@ -31,7 +33,8 @@ export function useArticleLoader({
|
||||
setHighlightsLoading,
|
||||
setCurrentArticleCoordinate,
|
||||
setCurrentArticleEventId,
|
||||
setCurrentArticle
|
||||
setCurrentArticle,
|
||||
settings
|
||||
}: UseArticleLoaderProps) {
|
||||
useEffect(() => {
|
||||
if (!relayPool || !naddr) return
|
||||
@@ -44,7 +47,7 @@ export function useArticleLoader({
|
||||
// Keep highlights panel collapsed by default - only open on user interaction
|
||||
|
||||
try {
|
||||
const article = await fetchArticleByNaddr(relayPool, naddr)
|
||||
const article = await fetchArticleByNaddr(relayPool, naddr, false, settings)
|
||||
setReaderContent({
|
||||
title: article.title,
|
||||
markdown: article.markdown,
|
||||
@@ -86,7 +89,8 @@ export function useArticleLoader({
|
||||
const highlightsList = Array.from(highlightsMap.values())
|
||||
setHighlights(highlightsList.sort((a, b) => b.created_at - a.created_at))
|
||||
}
|
||||
}
|
||||
},
|
||||
settings
|
||||
)
|
||||
console.log(`📌 Found ${highlightsMap.size} highlights`)
|
||||
} catch (err) {
|
||||
@@ -106,5 +110,5 @@ export function useArticleLoader({
|
||||
}
|
||||
|
||||
loadArticle()
|
||||
}, [naddr, relayPool, setSelectedUrl, setReaderContent, setReaderLoading, setIsCollapsed, setHighlights, setHighlightsLoading, setCurrentArticleCoordinate, setCurrentArticleEventId, setCurrentArticle])
|
||||
}, [naddr, relayPool, setSelectedUrl, setReaderContent, setReaderLoading, setIsCollapsed, setHighlights, setHighlightsLoading, setCurrentArticleCoordinate, setCurrentArticleEventId, setCurrentArticle, settings])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user