mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-24 01:41:42 +02:00
Store keyboard shortcut enablement per user and expose it in Profile settings. Co-Authored-By: Codie <Codie@users.noreply.github.com>
20 lines
627 B
TypeScript
20 lines
627 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { authApi } from "../api/auth";
|
|
import { queryKeys } from "../lib/queryKeys";
|
|
|
|
export function useUserPreferences() {
|
|
const session = useQuery({
|
|
queryKey: queryKeys.auth.session,
|
|
queryFn: () => authApi.getSession(),
|
|
retry: false,
|
|
});
|
|
const userId = session.data?.user?.id ?? null;
|
|
const preferences = useQuery({
|
|
queryKey: queryKeys.auth.preferences(userId),
|
|
queryFn: () => authApi.getPreferences(userId!),
|
|
enabled: !!userId,
|
|
retry: false,
|
|
});
|
|
return { ...preferences, data: preferences.isError ? undefined : preferences.data };
|
|
}
|