From 8e57d3d49179569efd81e2e067f0a1a3f892cf8d Mon Sep 17 00:00:00 2001 From: Gigi Date: Wed, 15 Oct 2025 10:01:43 +0200 Subject: [PATCH] refactor: remove unused settings parameter from image cache and bookmark components - Remove settings parameter from useImageCache and useCacheImageOnLoad hooks as it was never used - Update all call sites in CardView, CompactView, LargeView, and ReaderHeader - Remove settings prop from BookmarkItem and its child view components - Remove settings prop from BookmarkList component - Update ThreePaneLayout to not pass settings to BookmarkList This change cascades through the component tree to clean up unused props that were introduced when we refactored the image caching to use Service Worker instead of local storage. --- src/components/BookmarkItem.tsx | 7 ++----- src/components/BookmarkList.tsx | 4 ---- src/components/BookmarkViews/CardView.tsx | 7 ++----- src/components/BookmarkViews/CompactView.tsx | 7 ++----- src/components/BookmarkViews/LargeView.tsx | 7 ++----- src/components/ReaderHeader.tsx | 2 +- src/components/ThreePaneLayout.tsx | 1 - 7 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/components/BookmarkItem.tsx b/src/components/BookmarkItem.tsx index 0345bc37..bd97cbdd 100644 --- a/src/components/BookmarkItem.tsx +++ b/src/components/BookmarkItem.tsx @@ -11,17 +11,15 @@ import { getPreviewImage, fetchOgImage } from '../utils/imagePreview' import { CompactView } from './BookmarkViews/CompactView' import { LargeView } from './BookmarkViews/LargeView' import { CardView } from './BookmarkViews/CardView' -import { UserSettings } from '../services/settingsService' interface BookmarkItemProps { bookmark: IndividualBookmark index: number onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void viewMode?: ViewMode - settings?: UserSettings } -export const BookmarkItem: React.FC = ({ bookmark, index, onSelectUrl, viewMode = 'cards', settings }) => { +export const BookmarkItem: React.FC = ({ bookmark, index, onSelectUrl, viewMode = 'cards' }) => { const [ogImage, setOgImage] = useState(null) const short = (v: string) => `${v.slice(0, 8)}...${v.slice(-8)}` @@ -115,8 +113,7 @@ export const BookmarkItem: React.FC = ({ bookmark, index, onS getAuthorDisplayName, handleReadNow, articleImage, - articleSummary, - settings + articleSummary } if (viewMode === 'compact') { diff --git a/src/components/BookmarkList.tsx b/src/components/BookmarkList.tsx index e4036142..6b7a6244 100644 --- a/src/components/BookmarkList.tsx +++ b/src/components/BookmarkList.tsx @@ -9,7 +9,6 @@ import SidebarHeader from './SidebarHeader' import IconButton from './IconButton' import { ViewMode } from './Bookmarks' import { extractUrlsFromContent } from '../services/bookmarkHelpers' -import { UserSettings } from '../services/settingsService' import { usePullToRefresh } from 'use-pull-to-refresh' import RefreshIndicator from './RefreshIndicator' import { BookmarkSkeleton } from './Skeletons' @@ -29,7 +28,6 @@ interface BookmarkListProps { lastFetchTime?: number | null loading?: boolean relayPool: RelayPool | null - settings?: UserSettings isMobile?: boolean } @@ -48,7 +46,6 @@ export const BookmarkList: React.FC = ({ lastFetchTime, loading = false, relayPool, - settings, isMobile = false }) => { const bookmarksListRef = useRef(null) @@ -161,7 +158,6 @@ export const BookmarkList: React.FC = ({ index={index} onSelectUrl={onSelectUrl} viewMode={viewMode} - settings={settings} /> )} diff --git a/src/components/BookmarkViews/CardView.tsx b/src/components/BookmarkViews/CardView.tsx index 39361651..8af56045 100644 --- a/src/components/BookmarkViews/CardView.tsx +++ b/src/components/BookmarkViews/CardView.tsx @@ -10,7 +10,6 @@ import { classifyUrl } from '../../utils/helpers' import { IconGetter } from './shared' import { useImageCache } from '../../hooks/useImageCache' import { getPreviewImage, fetchOgImage } from '../../utils/imagePreview' -import { UserSettings } from '../../services/settingsService' import { getEventUrl } from '../../config/nostrGateways' interface CardViewProps { @@ -26,7 +25,6 @@ interface CardViewProps { handleReadNow: (e: React.MouseEvent) => void articleImage?: string articleSummary?: string - settings?: UserSettings } export const CardView: React.FC = ({ @@ -41,8 +39,7 @@ export const CardView: React.FC = ({ getAuthorDisplayName, handleReadNow, articleImage, - articleSummary, - settings + articleSummary }) => { const firstUrl = hasUrls ? extractedUrls[0] : null const firstUrlClassificationType = firstUrl ? classifyUrl(firstUrl)?.type : null @@ -59,7 +56,7 @@ export const CardView: React.FC = ({ // Determine which image to use (article image, instant preview, or OG image) const previewImage = articleImage || instantPreview || ogImage - const cachedImage = useImageCache(previewImage || undefined, settings) + const cachedImage = useImageCache(previewImage || undefined) // Fetch OG image if we don't have any other image React.useEffect(() => { diff --git a/src/components/BookmarkViews/CompactView.tsx b/src/components/BookmarkViews/CompactView.tsx index 86613d4b..f4d61499 100644 --- a/src/components/BookmarkViews/CompactView.tsx +++ b/src/components/BookmarkViews/CompactView.tsx @@ -5,7 +5,6 @@ import { IndividualBookmark } from '../../types/bookmarks' import { formatDateCompact } from '../../utils/bookmarkUtils' import ContentWithResolvedProfiles from '../ContentWithResolvedProfiles' import { useImageCache } from '../../hooks/useImageCache' -import { UserSettings } from '../../services/settingsService' interface CompactViewProps { bookmark: IndividualBookmark @@ -15,7 +14,6 @@ interface CompactViewProps { onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void articleImage?: string articleSummary?: string - settings?: UserSettings } export const CompactView: React.FC = ({ @@ -25,15 +23,14 @@ export const CompactView: React.FC = ({ extractedUrls, onSelectUrl, articleImage, - articleSummary, - settings + articleSummary }) => { const isArticle = bookmark.kind === 30023 const isWebBookmark = bookmark.kind === 39701 const isClickable = hasUrls || isArticle || isWebBookmark // Get cached image for thumbnail - const cachedImage = useImageCache(articleImage || undefined, settings) + const cachedImage = useImageCache(articleImage || undefined) const handleCompactClick = () => { if (!onSelectUrl) return diff --git a/src/components/BookmarkViews/LargeView.tsx b/src/components/BookmarkViews/LargeView.tsx index 116b3190..80001976 100644 --- a/src/components/BookmarkViews/LargeView.tsx +++ b/src/components/BookmarkViews/LargeView.tsx @@ -6,7 +6,6 @@ import { formatDate } from '../../utils/bookmarkUtils' import ContentWithResolvedProfiles from '../ContentWithResolvedProfiles' import { IconGetter } from './shared' import { useImageCache } from '../../hooks/useImageCache' -import { UserSettings } from '../../services/settingsService' import { getEventUrl } from '../../config/nostrGateways' interface LargeViewProps { @@ -22,7 +21,6 @@ interface LargeViewProps { getAuthorDisplayName: () => string handleReadNow: (e: React.MouseEvent) => void articleSummary?: string - settings?: UserSettings } export const LargeView: React.FC = ({ @@ -37,10 +35,9 @@ export const LargeView: React.FC = ({ eventNevent, getAuthorDisplayName, handleReadNow, - articleSummary, - settings + articleSummary }) => { - const cachedImage = useImageCache(previewImage || undefined, settings) + const cachedImage = useImageCache(previewImage || undefined) const isArticle = bookmark.kind === 30023 const triggerOpen = () => handleReadNow({ preventDefault: () => {} } as React.MouseEvent) diff --git a/src/components/ReaderHeader.tsx b/src/components/ReaderHeader.tsx index d6e348de..3a93f6ac 100644 --- a/src/components/ReaderHeader.tsx +++ b/src/components/ReaderHeader.tsx @@ -33,7 +33,7 @@ const ReaderHeader: React.FC = ({ highlights = [], highlightVisibility = { nostrverse: true, friends: true, mine: true } }) => { - const cachedImage = useImageCache(image, settings) + const cachedImage = useImageCache(image) const formattedDate = published ? format(new Date(published * 1000), 'MMM d, yyyy') : null const isLongSummary = summary && summary.length > 150 diff --git a/src/components/ThreePaneLayout.tsx b/src/components/ThreePaneLayout.tsx index 016f3650..05036530 100644 --- a/src/components/ThreePaneLayout.tsx +++ b/src/components/ThreePaneLayout.tsx @@ -303,7 +303,6 @@ const ThreePaneLayout: React.FC = (props) => { lastFetchTime={props.lastFetchTime} loading={props.bookmarksLoading} relayPool={props.relayPool} - settings={props.settings} isMobile={isMobile} />