diff --git a/rsconcept/frontend/src/context/LibraryContext.tsx b/rsconcept/frontend/src/context/LibraryContext.tsx index 72c8c428..850f7c26 100644 --- a/rsconcept/frontend/src/context/LibraryContext.tsx +++ b/rsconcept/frontend/src/context/LibraryContext.tsx @@ -65,7 +65,7 @@ interface LibraryStateProps { } export const LibraryState = ({ children }: LibraryStateProps) => { - const { user } = useAuth(); + const { user, loading: userLoading } = useAuth(); const { adminMode } = useConceptOptions(); const [items, setItems] = useState([]); @@ -175,16 +175,18 @@ export const LibraryState = ({ children }: LibraryStateProps) => { const reloadTemplates = useCallback(() => { setTemplates([]); getTemplates({ - setLoading: setLoading, - onError: setLoadingError, + setLoading: setProcessing, + onError: setProcessingError, showError: true, onSuccess: newData => setTemplates(newData) }); }, []); useEffect(() => { - reloadItems(); - }, [reloadItems]); + if (!userLoading) { + reloadItems(); + } + }, [reloadItems, userLoading]); useEffect(() => { reloadTemplates(); diff --git a/rsconcept/frontend/src/hooks/useOssDetails.ts b/rsconcept/frontend/src/hooks/useOssDetails.ts index ef202f99..7e186870 100644 --- a/rsconcept/frontend/src/hooks/useOssDetails.ts +++ b/rsconcept/frontend/src/hooks/useOssDetails.ts @@ -4,10 +4,12 @@ import { useCallback, useEffect, useState } from 'react'; import { getOssDetails } from '@/app/backendAPI'; import { type ErrorData } from '@/components/info/InfoError'; +import { useAuth } from '@/context/AuthContext'; import { IOperationSchema, IOperationSchemaData } from '@/models/oss'; import { OssLoader } from '@/models/OssLoader'; function useOssDetails({ target }: { target?: string }) { + const { loading: userLoading } = useAuth(); const [schema, setInner] = useState(undefined); const [loading, setLoading] = useState(true); const [error, setError] = useState(undefined); @@ -44,8 +46,10 @@ function useOssDetails({ target }: { target?: string }) { ); useEffect(() => { - reload(); - }, [reload]); + if (!userLoading) { + reload(); + } + }, [reload, userLoading]); return { schema, setSchema, reload, error, setError, loading }; } diff --git a/rsconcept/frontend/src/hooks/useRSFormDetails.ts b/rsconcept/frontend/src/hooks/useRSFormDetails.ts index 0d2d5144..b49d6a25 100644 --- a/rsconcept/frontend/src/hooks/useRSFormDetails.ts +++ b/rsconcept/frontend/src/hooks/useRSFormDetails.ts @@ -4,10 +4,12 @@ import { useCallback, useEffect, useState } from 'react'; import { getRSFormDetails } from '@/app/backendAPI'; import { type ErrorData } from '@/components/info/InfoError'; +import { useAuth } from '@/context/AuthContext'; import { IRSForm, IRSFormData } from '@/models/rsform'; import { RSFormLoader } from '@/models/RSFormLoader'; function useRSFormDetails({ target, version }: { target?: string; version?: string }) { + const { loading: userLoading } = useAuth(); const [schema, setInnerSchema] = useState(undefined); const [loading, setLoading] = useState(true); const [error, setError] = useState(undefined); @@ -44,8 +46,10 @@ function useRSFormDetails({ target, version }: { target?: string; version?: stri ); useEffect(() => { - reload(); - }, [reload]); + if (!userLoading) { + reload(); + } + }, [reload, userLoading]); return { schema, setSchema, reload, error, setError, loading }; }