mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 13:19:16 +00:00
Only show greeting once userConfig is fetched from server
- Pass userConfig from Home as prop to chatBodyData component with loading state - Pass loading state of userConfig to allow components to handle rendering dependent elements once it is loaded
This commit is contained in:
@@ -71,9 +71,9 @@ export interface UserConfig {
|
||||
|
||||
export function useUserConfig(detailed: boolean = false) {
|
||||
const url = `/api/settings?detailed=${detailed}`;
|
||||
const { data, error } = useSWR<UserConfig>(url, fetcher, { revalidateOnFocus: false });
|
||||
const { data: userConfig, error, isLoading: isLoadingUserConfig } = useSWR<UserConfig>(url, fetcher, { revalidateOnFocus: false });
|
||||
|
||||
if (error || !data || data.detail === 'Forbidden') return null;
|
||||
if (error || !userConfig || userConfig?.detail === 'Forbidden') return {userConfig: null, isLoadingUserConfig};
|
||||
|
||||
return data;
|
||||
return {userConfig, isLoadingUserConfig};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user