Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix(mobile): respect archiveDisplayBehaviour setting in lists and tags (#2499)

Mohamed Bassem59a256071237
diff --git a/apps/mobile/app/dashboard/lists/[slug]/index.tsx b/apps/mobile/app/dashboard/lists/[slug]/index.tsx
index 36ce491e..5df22f5e 100644
--- a/apps/mobile/app/dashboard/lists/[slug]/index.tsx
+++ b/apps/mobile/app/dashboard/lists/[slug]/index.tsx
@@ -4,6 +4,7 @@ import { router, Stack, useLocalSearchParams } from "expo-router";
import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList";
import FullPageError from "@/components/FullPageError";
import FullPageSpinner from "@/components/ui/FullPageSpinner";
+import { useArchiveFilter } from "@/lib/hooks";
import { MenuView } from "@react-native-menu/menu";
import { useMutation, useQuery } from "@tanstack/react-query";
import { Ellipsis } from "lucide-react-native";
@@ -22,6 +23,7 @@ export default function ListView() {
error,
refetch,
} = useQuery(api.lists.get.queryOptions({ listId: slug }));
+ const { archived, isLoading: isSettingsLoading } = useArchiveFilter();
return (
<>
@@ -36,10 +38,11 @@ export default function ListView() {
/>
{error ? (
<FullPageError error={error.message} onRetry={() => refetch()} />
- ) : list ? (
+ ) : list && !isSettingsLoading ? (
<UpdatingBookmarkList
query={{
listId: list.id,
+ archived,
}}
/>
) : (
diff --git a/apps/mobile/app/dashboard/tags/[slug].tsx b/apps/mobile/app/dashboard/tags/[slug].tsx
index 5fd9b886..32cffaaa 100644
--- a/apps/mobile/app/dashboard/tags/[slug].tsx
+++ b/apps/mobile/app/dashboard/tags/[slug].tsx
@@ -2,6 +2,7 @@ import { Stack, useLocalSearchParams } from "expo-router";
import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList";
import FullPageError from "@/components/FullPageError";
import FullPageSpinner from "@/components/ui/FullPageSpinner";
+import { useArchiveFilter } from "@/lib/hooks";
import { useQuery } from "@tanstack/react-query";
import { useTRPC } from "@karakeep/shared-react/trpc";
@@ -18,6 +19,7 @@ export default function TagView() {
error,
refetch,
} = useQuery(api.tags.get.queryOptions({ tagId: slug }));
+ const { archived, isLoading: isSettingsLoading } = useArchiveFilter();
return (
<>
@@ -29,10 +31,11 @@ export default function TagView() {
/>
{error ? (
<FullPageError error={error.message} onRetry={() => refetch()} />
- ) : tag ? (
+ ) : tag && !isSettingsLoading ? (
<UpdatingBookmarkList
query={{
tagId: tag.id,
+ archived,
}}
/>
) : (
diff --git a/apps/mobile/lib/hooks.ts b/apps/mobile/lib/hooks.ts
index c3cb9d22..ea4f068b 100644
--- a/apps/mobile/lib/hooks.ts
+++ b/apps/mobile/lib/hooks.ts
@@ -1,5 +1,7 @@
import { useQuery } from "@tanstack/react-query";
+import { useTRPC } from "@karakeep/shared-react/trpc";
+
import useAppSettings from "./settings";
import { buildApiHeaders } from "./utils";
@@ -37,3 +39,22 @@ export function useServerVersion() {
staleTime: 1000 * 60 * 5, // Cache for 5 minutes
});
}
+
+/**
+ * Hook to determine the appropriate archived filter value based on user settings.
+ * Returns `false` to hide archived bookmarks, or `undefined` to show all bookmarks.
+ */
+export function useArchiveFilter(): {
+ archived: false | undefined;
+ isLoading: boolean;
+} {
+ const api = useTRPC();
+ const { data: userSettings, isLoading } = useQuery(
+ api.users.settings.queryOptions(),
+ );
+ return {
+ archived:
+ userSettings?.archiveDisplayBehaviour === "show" ? undefined : false,
+ isLoading,
+ };
+}