diff options
| author | xuatz <xzlow10@gmail.com> | 2025-06-02 04:01:26 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-01 20:01:26 +0100 |
| commit | 3afe1e21df6dcc0483e74e0db02d9d82af32ecea (patch) | |
| tree | 32208bf2de6fedae00aaeb4f7ca0d74a816b4764 /apps/web/app | |
| parent | 8784c73c112b5b87bcf48670401e3956464ea436 (diff) | |
| download | karakeep-3afe1e21df6dcc0483e74e0db02d9d82af32ecea.tar.zst | |
feat: add user customisable default archive display behaviour (#1505)
* fix typo
* implementation
* bug fix and refactoring
* Use nuqs for searchParam management
* remove the todo about the tests
* fix tests
---------
Co-authored-by: Mohamed Bassem <me@mbassem.com>
Diffstat (limited to 'apps/web/app')
| -rw-r--r-- | apps/web/app/dashboard/lists/[listId]/page.tsx | 15 | ||||
| -rw-r--r-- | apps/web/app/dashboard/tags/[tagId]/page.tsx | 15 | ||||
| -rw-r--r-- | apps/web/app/layout.tsx | 21 |
3 files changed, 40 insertions, 11 deletions
diff --git a/apps/web/app/dashboard/lists/[listId]/page.tsx b/apps/web/app/dashboard/lists/[listId]/page.tsx index 6c0bc36c..de0f5054 100644 --- a/apps/web/app/dashboard/lists/[listId]/page.tsx +++ b/apps/web/app/dashboard/lists/[listId]/page.tsx @@ -8,9 +8,14 @@ import { BookmarkListContextProvider } from "@karakeep/shared-react/hooks/bookma export default async function ListPage({ params, + searchParams, }: { params: { listId: string }; + searchParams?: { + includeArchived?: string; + }; }) { + const userSettings = await api.users.settings(); let list; try { list = await api.lists.get({ listId: params.listId }); @@ -23,10 +28,18 @@ export default async function ListPage({ throw e; } + const includeArchived = + searchParams?.includeArchived !== undefined + ? searchParams.includeArchived === "true" + : userSettings.archiveDisplayBehaviour === "show"; + return ( <BookmarkListContextProvider list={list}> <Bookmarks - query={{ listId: list.id }} + query={{ + listId: list.id, + archived: !includeArchived ? false : undefined, + }} showDivider={true} showEditorCard={list.type === "manual"} header={<ListHeader initialData={list} />} diff --git a/apps/web/app/dashboard/tags/[tagId]/page.tsx b/apps/web/app/dashboard/tags/[tagId]/page.tsx index f6e02a65..b33a351a 100644 --- a/apps/web/app/dashboard/tags/[tagId]/page.tsx +++ b/apps/web/app/dashboard/tags/[tagId]/page.tsx @@ -9,8 +9,12 @@ import { MoreHorizontal } from "lucide-react"; export default async function TagPage({ params, + searchParams, }: { params: { tagId: string }; + searchParams?: { + includeArchived?: string; + }; }) { let tag; try { @@ -23,6 +27,12 @@ export default async function TagPage({ } throw e; } + const userSettings = await api.users.settings(); + + const includeArchived = + searchParams?.includeArchived !== undefined + ? searchParams.includeArchived === "true" + : userSettings.archiveDisplayBehaviour === "show"; return ( <Bookmarks @@ -40,7 +50,10 @@ export default async function TagPage({ </TagOptions> </div> } - query={{ tagId: tag.id }} + query={{ + tagId: tag.id, + archived: !includeArchived ? false : undefined, + }} showEditorCard={true} /> ); diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index beeecc2b..d5af9e35 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -1,5 +1,6 @@ import type { Metadata } from "next"; import { Inter } from "next/font/google"; +import { NuqsAdapter } from "nuqs/adapters/next/app"; import "@karakeep/tailwind-config/globals.css"; @@ -55,15 +56,17 @@ export default async function RootLayout({ dir={isRTL ? "rtl" : "ltr"} > <body className={inter.className}> - <Providers - session={session} - clientConfig={clientConfig} - userLocalSettings={await getUserLocalSettings()} - > - {children} - <ReactQueryDevtools initialIsOpen={false} /> - </Providers> - <Toaster /> + <NuqsAdapter> + <Providers + session={session} + clientConfig={clientConfig} + userLocalSettings={await getUserLocalSettings()} + > + {children} + <ReactQueryDevtools initialIsOpen={false} /> + </Providers> + <Toaster /> + </NuqsAdapter> </body> </html> ); |
