mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Wait for user loading before loading Library or Schema
Some checks are pending
Frontend CI / build (18.x) (push) Waiting to run
Some checks are pending
Frontend CI / build (18.x) (push) Waiting to run
This commit is contained in:
parent
c2417eb760
commit
e12cb3821b
|
@ -65,7 +65,7 @@ interface LibraryStateProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LibraryState = ({ children }: LibraryStateProps) => {
|
export const LibraryState = ({ children }: LibraryStateProps) => {
|
||||||
const { user } = useAuth();
|
const { user, loading: userLoading } = useAuth();
|
||||||
const { adminMode } = useConceptOptions();
|
const { adminMode } = useConceptOptions();
|
||||||
|
|
||||||
const [items, setItems] = useState<ILibraryItem[]>([]);
|
const [items, setItems] = useState<ILibraryItem[]>([]);
|
||||||
|
@ -175,16 +175,18 @@ export const LibraryState = ({ children }: LibraryStateProps) => {
|
||||||
const reloadTemplates = useCallback(() => {
|
const reloadTemplates = useCallback(() => {
|
||||||
setTemplates([]);
|
setTemplates([]);
|
||||||
getTemplates({
|
getTemplates({
|
||||||
setLoading: setLoading,
|
setLoading: setProcessing,
|
||||||
onError: setLoadingError,
|
onError: setProcessingError,
|
||||||
showError: true,
|
showError: true,
|
||||||
onSuccess: newData => setTemplates(newData)
|
onSuccess: newData => setTemplates(newData)
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!userLoading) {
|
||||||
reloadItems();
|
reloadItems();
|
||||||
}, [reloadItems]);
|
}
|
||||||
|
}, [reloadItems, userLoading]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reloadTemplates();
|
reloadTemplates();
|
||||||
|
|
|
@ -4,10 +4,12 @@ import { useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { getOssDetails } from '@/app/backendAPI';
|
import { getOssDetails } from '@/app/backendAPI';
|
||||||
import { type ErrorData } from '@/components/info/InfoError';
|
import { type ErrorData } from '@/components/info/InfoError';
|
||||||
|
import { useAuth } from '@/context/AuthContext';
|
||||||
import { IOperationSchema, IOperationSchemaData } from '@/models/oss';
|
import { IOperationSchema, IOperationSchemaData } from '@/models/oss';
|
||||||
import { OssLoader } from '@/models/OssLoader';
|
import { OssLoader } from '@/models/OssLoader';
|
||||||
|
|
||||||
function useOssDetails({ target }: { target?: string }) {
|
function useOssDetails({ target }: { target?: string }) {
|
||||||
|
const { loading: userLoading } = useAuth();
|
||||||
const [schema, setInner] = useState<IOperationSchema | undefined>(undefined);
|
const [schema, setInner] = useState<IOperationSchema | undefined>(undefined);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<ErrorData>(undefined);
|
const [error, setError] = useState<ErrorData>(undefined);
|
||||||
|
@ -44,8 +46,10 @@ function useOssDetails({ target }: { target?: string }) {
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!userLoading) {
|
||||||
reload();
|
reload();
|
||||||
}, [reload]);
|
}
|
||||||
|
}, [reload, userLoading]);
|
||||||
|
|
||||||
return { schema, setSchema, reload, error, setError, loading };
|
return { schema, setSchema, reload, error, setError, loading };
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,12 @@ import { useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { getRSFormDetails } from '@/app/backendAPI';
|
import { getRSFormDetails } from '@/app/backendAPI';
|
||||||
import { type ErrorData } from '@/components/info/InfoError';
|
import { type ErrorData } from '@/components/info/InfoError';
|
||||||
|
import { useAuth } from '@/context/AuthContext';
|
||||||
import { IRSForm, IRSFormData } from '@/models/rsform';
|
import { IRSForm, IRSFormData } from '@/models/rsform';
|
||||||
import { RSFormLoader } from '@/models/RSFormLoader';
|
import { RSFormLoader } from '@/models/RSFormLoader';
|
||||||
|
|
||||||
function useRSFormDetails({ target, version }: { target?: string; version?: string }) {
|
function useRSFormDetails({ target, version }: { target?: string; version?: string }) {
|
||||||
|
const { loading: userLoading } = useAuth();
|
||||||
const [schema, setInnerSchema] = useState<IRSForm | undefined>(undefined);
|
const [schema, setInnerSchema] = useState<IRSForm | undefined>(undefined);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<ErrorData>(undefined);
|
const [error, setError] = useState<ErrorData>(undefined);
|
||||||
|
@ -44,8 +46,10 @@ function useRSFormDetails({ target, version }: { target?: string; version?: stri
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!userLoading) {
|
||||||
reload();
|
reload();
|
||||||
}, [reload]);
|
}
|
||||||
|
}, [reload, userLoading]);
|
||||||
|
|
||||||
return { schema, setSchema, reload, error, setError, loading };
|
return { schema, setSchema, reload, error, setError, loading };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user