Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COJ] Shaheer / Hooks / Fixes useSettings hook #13529

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/api/src/hooks/useSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback, useMemo } from 'react';
import useAuthorize from './useAuthorize';
import useQuery from '../useQuery';
import useInvalidateQuery from '../useInvalidateQuery';
import useMutation from '../useMutation';
Expand All @@ -9,7 +10,8 @@ type TSetSettingsPayload = NonNullable<

/** A custom hook to get and update the user settings. */
const useSettings = () => {
const { data, ...rest } = useQuery('get_settings');
const { isSuccess } = useAuthorize();
const { data, ...rest } = useQuery('get_settings', { options: { enabled: isSuccess } });
amina-deriv marked this conversation as resolved.
Show resolved Hide resolved
const { mutate, ...mutate_rest } = useMutation('set_settings', { onSuccess: () => invalidate('get_settings') });
const invalidate = useInvalidateQuery();

Expand Down