From ea1d0023bfee55358ebb1a96f3d06e783a219c0d Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 1 Jun 2025 20:46:41 +0100 Subject: feat: Add support for public lists (#1511) * WIP: public lists * Drop viewing modes * Add the public endpoint for assets * regen the openapi spec * proper handling for different asset types * Add num bookmarks and a no bookmark banner * Correctly set page title * Add a not-found page * merge the RSS and public list endpoints * Add e2e tests for the public endpoints * Redesign the share list modal * Make NEXTAUTH_SECRET not required * propery render text bookmarks * rebase migration * fix public token tests * Add more tests --- packages/shared/utils/bookmarkUtils.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'packages/shared/utils/bookmarkUtils.ts') diff --git a/packages/shared/utils/bookmarkUtils.ts b/packages/shared/utils/bookmarkUtils.ts index 31d7b698..97ef08fc 100644 --- a/packages/shared/utils/bookmarkUtils.ts +++ b/packages/shared/utils/bookmarkUtils.ts @@ -3,18 +3,32 @@ import { getAssetUrl } from "./assetUtils"; const MAX_LOADING_MSEC = 30 * 1000; -export function getBookmarkLinkImageUrl(bookmark: ZBookmarkedLink) { +export function getBookmarkLinkAssetIdOrUrl(bookmark: ZBookmarkedLink) { if (bookmark.imageAssetId) { - return { url: getAssetUrl(bookmark.imageAssetId), localAsset: true }; + return { assetId: bookmark.imageAssetId, localAsset: true as const }; } if (bookmark.screenshotAssetId) { - return { url: getAssetUrl(bookmark.screenshotAssetId), localAsset: true }; + return { assetId: bookmark.screenshotAssetId, localAsset: true as const }; } return bookmark.imageUrl - ? { url: bookmark.imageUrl, localAsset: false } + ? { url: bookmark.imageUrl, localAsset: false as const } : null; } +export function getBookmarkLinkImageUrl(bookmark: ZBookmarkedLink) { + const assetOrUrl = getBookmarkLinkAssetIdOrUrl(bookmark); + if (!assetOrUrl) { + return null; + } + if (!assetOrUrl.localAsset) { + return assetOrUrl; + } + return { + url: getAssetUrl(assetOrUrl.assetId), + localAsset: true, + }; +} + export function isBookmarkStillCrawling(bookmark: ZBookmark) { return ( bookmark.content.type == BookmarkTypes.LINK && -- cgit v1.2.3-70-g09d2