mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 21:29:08 +00:00
Merge pull request #1015 from khoj-ai/features/clean-up-authenticated-data
- De facto, was being assumed everywhere if authenticatedData is null, that it's not logged in. This isn't true because the data can still be loading. Update the hook to send additional states. - Bonus: Delete model picker code and a slew of unused imports.
This commit is contained in:
@@ -19,13 +19,15 @@ const fetcher = (url: string) =>
|
||||
.catch((err) => console.warn(err));
|
||||
|
||||
export function useAuthenticatedData() {
|
||||
const { data, error } = useSWR<UserProfile>("/api/v1/user", fetcher, {
|
||||
const { data, error, isLoading } = useSWR<UserProfile>("/api/v1/user", fetcher, {
|
||||
revalidateOnFocus: false,
|
||||
});
|
||||
|
||||
if (error || !data || data.detail === "Forbidden") return null;
|
||||
if (data?.detail === "Forbidden") {
|
||||
return { data: null, error: "Forbidden", isLoading: false };
|
||||
}
|
||||
|
||||
return data;
|
||||
return { data, error, isLoading };
|
||||
}
|
||||
|
||||
export interface ModelOptions {
|
||||
|
||||
Reference in New Issue
Block a user