diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-05-24 12:59:43 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-05-24 12:59:43 +0000 |
| commit | 09652176f97f11bc06f4c9b57a448e14744eac12 (patch) | |
| tree | 5205f65bdef233328a7b4af010667c5b8c25f285 /apps/web/lib | |
| parent | 5f3fe5d1a1ad0abd2890283cbff45086cbfa442e (diff) | |
| download | karakeep-09652176f97f11bc06f4c9b57a448e14744eac12.tar.zst | |
feat: Allow defaulting to reader mode when clicking on bookmarks. Fixes #662
Diffstat (limited to 'apps/web/lib')
| -rw-r--r-- | apps/web/lib/i18n/locales/en/translation.json | 8 | ||||
| -rw-r--r-- | apps/web/lib/userSettings.tsx | 33 |
2 files changed, 40 insertions, 1 deletions
diff --git a/apps/web/lib/i18n/locales/en/translation.json b/apps/web/lib/i18n/locales/en/translation.json index 1eef3ac4..48d32f37 100644 --- a/apps/web/lib/i18n/locales/en/translation.json +++ b/apps/web/lib/i18n/locales/en/translation.json @@ -98,7 +98,13 @@ "new_password": "New Password", "confirm_new_password": "Confirm New Password", "options": "Options", - "interface_lang": "Interface Language" + "interface_lang": "Interface Language", + "user_settings": { + "user_settings_updated": "User settings have been updated!", + "boomark_click_action": "Bookmark Click Action", + "open_external_url": "Open Original URL", + "open_bookmark_details": "Open Bookmark Details" + } }, "ai": { "ai_settings": "AI Settings", 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); +} |
