diff --git a/app/article/article-wrapper.tsx b/app/article/article-wrapper.tsx index b2775b0..a494ea2 100644 --- a/app/article/article-wrapper.tsx +++ b/app/article/article-wrapper.tsx @@ -17,6 +17,9 @@ import { getUrlWithoutPaywall } from "./actions/url"; export const getCachedArticle = unstable_cache( async (url) => scrapeArticleContent(url), ["url"], + { + revalidate: 60 * 60, // 1 hour + }, ); async function ArticleLoader({ url }: { url: string }) { diff --git a/app/bookmarks/components/bookmark-list.tsx b/app/bookmarks/components/bookmark-list.tsx index 346a103..b3dca0d 100644 --- a/app/bookmarks/components/bookmark-list.tsx +++ b/app/bookmarks/components/bookmark-list.tsx @@ -22,12 +22,13 @@ import { AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { Bookmark } from "../bookmark-wrapper"; -import { usePathname, useSearchParams } from "next/navigation"; +import { usePathname, useRouter, useSearchParams } from "next/navigation"; import * as cheerio from "cheerio"; import { useEffect, useMemo, useState } from "react"; import { BookmarksSearchBox } from "./bookmarks-search-box"; import { BookmarksDisplayMenu } from "./bookmarks-display"; import { BookmarkButton } from "./bookmark-button"; +import Image from "next/image"; export type Layout = "grid" | "rows"; export type OrderBy = "date" | "readTime" | "title"; @@ -56,6 +57,8 @@ export default function BookmarksList({ userId: number; }) { const { toast } = useToast(); + + const router = useRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); const searchTerm = searchParams.get("search") || ""; @@ -124,105 +127,147 @@ export default function BookmarksList({
- {sortedAndFilteredBookmarks.map((bookmark) => ( - - -
-
- - - CN - -
- - {bookmark.authorName} - -
- {bookmark.readTime} - {bookmark.publishDate && ·} - {bookmark.publishDate && formatDate(bookmark.publishDate)} + {sortedAndFilteredBookmarks.length > 0 ? ( + sortedAndFilteredBookmarks.map((bookmark) => ( + + +
+
+ + + CN + +
+ + {bookmark.authorName} + +
+ {bookmark.readTime} + {bookmark.publishDate && ( + · + )} + {bookmark.publishDate && + formatDate(bookmark.publishDate)} +
-
- - - - - - - - Are you absolutely sure? - - - This action will remove the bookmark from your list. - - - - Cancel - { - const [_, error] = await deleteBookmarkAction({ - path: pathname, - id: bookmark.id, - userId: userId, - }); - - if (error) { + + + + + + + + Are you absolutely sure? + + + This action will remove the bookmark from your list. + + + + Cancel + { + const [_, error] = await deleteBookmarkAction({ + path: pathname, + id: bookmark.id, + userId: userId, + }); + + if (error) { + toast({ + title: "Error", + description: "Failed to delete bookmark", + variant: "destructive", + }); + return; + } + toast({ - title: "Error", - description: "Failed to delete bookmark", - variant: "destructive", + title: "Bookmark deleted", + description: + "Bookmark has been successfully deleted", }); - return; - } - - toast({ - title: "Bookmark deleted", - description: - "Bookmark has been successfully deleted", - }); - }} - > - Continue - - - - -
- - {bookmark.title} - - - {extractFirstSentence(bookmark.content)} - - + }} + > + Continue + + + + +
+ + {bookmark.title} + + + {extractFirstSentence(bookmark.content)} + + + + )) + ) : ( + + Error +
+

Bookmark not found!

+

+ Bummer! The bookmark you are looking for does not exist. You + either typed in the wrong article name or you didn't + bookmark the article. +

+ +
- ))} + )}
);