import React from 'react' import { Link } from 'react-router-dom' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { IconDefinition } from '@fortawesome/fontawesome-svg-core' import { IndividualBookmark } from '../../types/bookmarks' import { formatDate } from '../../utils/bookmarkUtils' import RichContent from '../RichContent' import { IconGetter } from './shared' import { useImageCache } from '../../hooks/useImageCache' import { naddrEncode } from 'nostr-tools/nip19' import { ReadingProgressBar } from '../ReadingProgressBar' interface LargeViewProps { bookmark: IndividualBookmark index: number hasUrls: boolean extractedUrls: string[] onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void getIconForUrlType: IconGetter previewImage: string | null authorNpub: string getAuthorDisplayName: () => string handleReadNow: (e: React.MouseEvent) => void articleSummary?: string contentTypeIcon: IconDefinition readingProgress?: number // 0-1 reading progress (optional) } export const LargeView: React.FC = ({ bookmark, index, hasUrls, extractedUrls, onSelectUrl, getIconForUrlType, previewImage, authorNpub, getAuthorDisplayName, handleReadNow, articleSummary, contentTypeIcon, readingProgress }) => { const cachedImage = useImageCache(previewImage || undefined) const isArticle = bookmark.kind === 30023 const triggerOpen = () => handleReadNow({ preventDefault: () => {} } as React.MouseEvent) const handleKeyDown: React.KeyboardEventHandler = (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() triggerOpen() } } // Get internal route for the bookmark const getInternalRoute = (): string | null => { const firstUrl = hasUrls ? extractedUrls[0] : null if (bookmark.kind === 30023) { // Nostr-native article - use /a/ route const dTag = bookmark.tags.find(t => t[0] === 'd')?.[1] if (dTag) { const naddr = naddrEncode({ kind: bookmark.kind, pubkey: bookmark.pubkey, identifier: dTag }) return `/a/${naddr}` } } else if (bookmark.kind === 1) { // Note - use /e/ route return `/e/${bookmark.id}` } else if (firstUrl) { // External URL - use /r/ route return `/r/${encodeURIComponent(firstUrl)}` } return null } return (
{(hasUrls || (isArticle && cachedImage)) && (
{ e.stopPropagation() if (isArticle) { handleReadNow({ preventDefault: () => {} } as React.MouseEvent) } else { onSelectUrl?.(extractedUrls[0]) } }} style={cachedImage ? { backgroundImage: `url(${cachedImage})` } : undefined} > {!previewImage && hasUrls && (
)}
)}
{isArticle && articleSummary ? ( ) : bookmark.content && ( )} {/* Reading progress indicator for all bookmark types - always shown */}
e.stopPropagation()} > {getAuthorDisplayName()} {getInternalRoute() ? ( e.stopPropagation()} > {formatDate(bookmark.created_at ?? bookmark.listUpdatedAt)} ) : ( {formatDate(bookmark.created_at ?? bookmark.listUpdatedAt)} )} {/* CTA removed */}
) }