♻️(frontend) rename isLoading to isConfigLoading for clarity
Rename generic "isLoading" variable to more specific "isConfigLoading" to accurately reflect its purpose. Improves code readability by making state variable names more explicit.
This commit is contained in:
committed by
aleb_the_flash
parent
8e0e286bc4
commit
7f0e866eac
@@ -24,24 +24,25 @@ export const useUser = (
|
|||||||
fetchUserOptions?: Parameters<typeof fetchUser>[0]
|
fetchUserOptions?: Parameters<typeof fetchUser>[0]
|
||||||
} = {}
|
} = {}
|
||||||
) => {
|
) => {
|
||||||
const { data, isLoading } = useConfig()
|
const { data, isLoading: isConfigLoading } = useConfig()
|
||||||
|
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
if (!data || data?.is_silent_login_enabled !== true) {
|
if (isConfigLoading) return
|
||||||
|
if (data?.is_silent_login_enabled !== true) {
|
||||||
return {
|
return {
|
||||||
...opts,
|
...opts,
|
||||||
attemptSilent: false,
|
attemptSilent: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return opts.fetchUserOptions
|
return opts.fetchUserOptions
|
||||||
}, [data, opts])
|
}, [data, opts, isConfigLoading])
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
// eslint-disable-next-line @tanstack/query/exhaustive-deps
|
// eslint-disable-next-line @tanstack/query/exhaustive-deps
|
||||||
queryKey: [keys.user],
|
queryKey: [keys.user],
|
||||||
queryFn: () => fetchUser(options),
|
queryFn: () => fetchUser(options),
|
||||||
staleTime: Infinity,
|
staleTime: Infinity,
|
||||||
enabled: !isLoading,
|
enabled: !isConfigLoading,
|
||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user