mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 07:34:28 +01:00
fix: prevent tracking reading position for nostr-event sentinel URLs
- Add check to filter out nostr-event: URLs from reading position tracking - nostr-event: is an internal sentinel, not a valid Nostr URI per NIP-21 - Prevents these sentinel URLs from being saved to reading position data
This commit is contained in:
@@ -155,6 +155,8 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
|||||||
const isTextContent = useMemo(() => {
|
const isTextContent = useMemo(() => {
|
||||||
if (loading) return false
|
if (loading) return false
|
||||||
if (!markdown && !html) return false
|
if (!markdown && !html) return false
|
||||||
|
// Don't track internal sentinel URLs (nostr-event: is not a real Nostr URI per NIP-21)
|
||||||
|
if (selectedUrl?.startsWith('nostr-event:')) return false
|
||||||
if (selectedUrl?.includes('youtube') || selectedUrl?.includes('vimeo')) return false
|
if (selectedUrl?.includes('youtube') || selectedUrl?.includes('vimeo')) return false
|
||||||
if (!shouldTrackReadingProgress(html, markdown)) return false
|
if (!shouldTrackReadingProgress(html, markdown)) return false
|
||||||
|
|
||||||
|
|||||||
@@ -394,22 +394,8 @@ const Me: React.FC<MeProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getReadItemUrl = (item: ReadItem) => {
|
const getReadItemUrl = (item: ReadItem) => {
|
||||||
// Handle nostr-event: URLs specially - route to /e/ path
|
if (item.type === 'article' && item.id.startsWith('naddr1')) {
|
||||||
const urlToCheck = item.url || item.id
|
|
||||||
if (urlToCheck?.startsWith('nostr-event:')) {
|
|
||||||
const eventId = urlToCheck.replace('nostr-event:', '')
|
|
||||||
return `/e/${eventId}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.type === 'article') {
|
|
||||||
// Check if ID is actually an naddr
|
|
||||||
if (item.id.startsWith('naddr1')) {
|
|
||||||
return `/a/${item.id}`
|
return `/a/${item.id}`
|
||||||
}
|
|
||||||
// Fallback: if it has a URL, use /r/ path
|
|
||||||
if (item.url) {
|
|
||||||
return `/r/${encodeURIComponent(item.url)}`
|
|
||||||
}
|
|
||||||
} else if (item.url) {
|
} else if (item.url) {
|
||||||
return `/r/${encodeURIComponent(item.url)}`
|
return `/r/${encodeURIComponent(item.url)}`
|
||||||
}
|
}
|
||||||
@@ -450,27 +436,17 @@ const Me: React.FC<MeProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSelectUrl = (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => {
|
const handleSelectUrl = (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => {
|
||||||
// Handle nostr-event: URLs specially - route to /e/ path
|
|
||||||
if (url?.startsWith('nostr-event:')) {
|
|
||||||
const eventId = url.replace('nostr-event:', '')
|
|
||||||
navigate(`/e/${eventId}`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bookmark && bookmark.kind === 30023) {
|
if (bookmark && bookmark.kind === 30023) {
|
||||||
// For kind:30023 articles, navigate to the article route
|
|
||||||
const dTag = bookmark.tags.find(t => t[0] === 'd')?.[1] || ''
|
const dTag = bookmark.tags.find(t => t[0] === 'd')?.[1] || ''
|
||||||
if (dTag && bookmark.pubkey) {
|
if (dTag && bookmark.pubkey) {
|
||||||
const pointer = {
|
const naddr = nip19.naddrEncode({
|
||||||
identifier: dTag,
|
|
||||||
kind: 30023,
|
kind: 30023,
|
||||||
pubkey: bookmark.pubkey,
|
pubkey: bookmark.pubkey,
|
||||||
}
|
identifier: dTag
|
||||||
const naddr = nip19.naddrEncode(pointer)
|
})
|
||||||
navigate(`/a/${naddr}`)
|
navigate(`/a/${naddr}`)
|
||||||
}
|
}
|
||||||
} else if (url) {
|
} else if (url) {
|
||||||
// For regular URLs, navigate to the reader route
|
|
||||||
navigate(`/r/${encodeURIComponent(url)}`)
|
navigate(`/r/${encodeURIComponent(url)}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user