From 09652176f97f11bc06f4c9b57a448e14744eac12 Mon Sep 17 00:00:00 2001
From: Mohamed Bassem <me@mbassem.com>
Date: Sat, 24 May 2025 12:59:43 +0000
Subject: feat: Allow defaulting to reader mode when clicking on bookmarks.
 Fixes #662

---
 apps/web/lib/userSettings.tsx | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 apps/web/lib/userSettings.tsx

(limited to 'apps/web/lib/userSettings.tsx')

diff --git a/apps/web/lib/userSettings.tsx b/apps/web/lib/userSettings.tsx
new file mode 100644
index 00000000..727c823e
--- /dev/null
+++ b/apps/web/lib/userSettings.tsx
@@ -0,0 +1,33 @@
+"use client";
+
+import { createContext, useContext } from "react";
+
+import { ZUserSettings } from "@karakeep/shared/types/users";
+
+import { api } from "./trpc";
+
+export const UserSettingsContext = createContext<ZUserSettings>({
+  bookmarkClickAction: "open_original_link",
+});
+
+export function UserSettingsContextProvider({
+  userSettings,
+  children,
+}: {
+  userSettings: ZUserSettings;
+  children: React.ReactNode;
+}) {
+  const { data } = api.users.settings.useQuery(undefined, {
+    initialData: userSettings,
+  });
+
+  return (
+    <UserSettingsContext.Provider value={data}>
+      {children}
+    </UserSettingsContext.Provider>
+  );
+}
+
+export function useUserSettings() {
+  return useContext(UserSettingsContext);
+}
-- 
cgit v1.2.3-70-g09d2

