From 0b5bf59e98ea786f0932719ddf163ea1bdef9bff Mon Sep 17 00:00:00 2001 From: Gigi Date: Tue, 7 Oct 2025 18:37:45 +0100 Subject: [PATCH] feat: hide bookmarks without content or URL --- src/components/BookmarkList.tsx | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/components/BookmarkList.tsx b/src/components/BookmarkList.tsx index d0f95aae..e8742c12 100644 --- a/src/components/BookmarkList.tsx +++ b/src/components/BookmarkList.tsx @@ -1,11 +1,12 @@ import React from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faChevronLeft, faBookmark, faSpinner, faList, faThLarge, faImage } from '@fortawesome/free-solid-svg-icons' -import { Bookmark } from '../types/bookmarks' +import { Bookmark, IndividualBookmark } from '../types/bookmarks' import { BookmarkItem } from './BookmarkItem' import SidebarHeader from './SidebarHeader' import IconButton from './IconButton' import { ViewMode } from './Bookmarks' +import { extractUrlsFromContent } from '../services/bookmarkHelpers' interface BookmarkListProps { bookmarks: Bookmark[] @@ -36,10 +37,35 @@ export const BookmarkList: React.FC = ({ isRefreshing, loading = false }) => { + // Helper to check if a bookmark has either content or a URL + const hasContentOrUrl = (ib: IndividualBookmark) => { + // Check if has content (text) + const hasContent = ib.content && ib.content.trim().length > 0 + + // Check if has URL + let hasUrl = false + + // For web bookmarks (kind:39701), URL is in the 'd' tag + if (ib.kind === 39701) { + const dTag = ib.tags?.find((t: string[]) => t[0] === 'd')?.[1] + hasUrl = !!dTag && dTag.trim().length > 0 + } else { + // For other bookmarks, extract URLs from content + const urls = extractUrlsFromContent(ib.content || '') + hasUrl = urls.length > 0 + } + + // Always show articles (kind:30023) as they have special handling + if (ib.kind === 30023) return true + + // Otherwise, must have either content or URL + return hasContent || hasUrl + } + // Merge and flatten all individual bookmarks from all lists // Re-sort after flattening to ensure newest first across all lists const allIndividualBookmarks = bookmarks.flatMap(b => b.individualBookmarks || []) - .filter(ib => ib.content || ib.kind === 30023 || ib.kind === 39701) + .filter(hasContentOrUrl) .sort((a, b) => ((b.added_at || 0) - (a.added_at || 0)) || ((b.created_at || 0) - (a.created_at || 0))) if (isCollapsed) {