aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/utils
diff options
context:
space:
mode:
authorxuatz <xzlow10@gmail.com>2025-06-02 04:01:26 +0900
committerGitHub <noreply@github.com>2025-06-01 20:01:26 +0100
commit3afe1e21df6dcc0483e74e0db02d9d82af32ecea (patch)
tree32208bf2de6fedae00aaeb4f7ca0d74a816b4764 /apps/web/components/utils
parent8784c73c112b5b87bcf48670401e3956464ea436 (diff)
downloadkarakeep-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/components/utils')
-rw-r--r--apps/web/components/utils/useShowArchived.tsx24
1 files changed, 24 insertions, 0 deletions
diff --git a/apps/web/components/utils/useShowArchived.tsx b/apps/web/components/utils/useShowArchived.tsx
new file mode 100644
index 00000000..3fc66e91
--- /dev/null
+++ b/apps/web/components/utils/useShowArchived.tsx
@@ -0,0 +1,24 @@
+import { useCallback } from "react";
+import { useUserSettings } from "@/lib/userSettings";
+import { parseAsBoolean, useQueryState } from "nuqs";
+
+export function useShowArchived() {
+ const userSettings = useUserSettings();
+ const [showArchived, setShowArchived] = useQueryState(
+ "includeArchived",
+ parseAsBoolean
+ .withOptions({
+ shallow: false,
+ })
+ .withDefault(userSettings.archiveDisplayBehaviour === "show"),
+ );
+
+ const onClickShowArchived = useCallback(() => {
+ setShowArchived((prev) => !prev);
+ }, [setShowArchived]);
+
+ return {
+ showArchived,
+ onClickShowArchived,
+ };
+}