Skip to content

Commit

Permalink
Update react-query-service.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
bsu3338 committed Apr 12, 2024
1 parent 39de165 commit be9e53c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/data-provider/src/react-query/react-query-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,40 @@ export const useUpdateUserPluginsMutation = (): UseMutationResult<
});
};

export const usePreferenceQuery = (
name: string,
config?: UseQueryOptions<t.TPreference>,
): QueryObserverResult<
t.TPreference
> => {
return useQuery<t.TPreference>(
[QueryKeys.name, name],
() => {
return dataService.getUserPreference(name);
},
{
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
retry: false,
},
);
};

export const useUpdatePreferenceMutation = (): UseMutationResult<
t.TUser,
unknown,
t.TPreference,
unknown
> => {
const queryClient = useQueryClient();
return useMutation((payload: t.TPreference) => dataService.updateUserPreference(payload), {
onSuccess: (data, variables) => {
queryClient.invalidateQueries([QueryKeys.name, variables.name]);
},
});
};

export const useGetStartupConfig = (): QueryObserverResult<t.TStartupConfig> => {
return useQuery<t.TStartupConfig>(
[QueryKeys.startupConfig],
Expand Down

0 comments on commit be9e53c

Please sign in to comment.