Fix context loading semantics
Some checks failed
Backend CI / build (3.12) (push) Has been cancelled
Frontend CI / build (18.x) (push) Has been cancelled

Loading is a flag for data loading on context create
Processing is a flag for waiting for response after function call
This commit is contained in:
IRBorisov 2024-06-23 19:43:22 +03:00
parent c430a0132c
commit 122bf4fcc1
9 changed files with 21 additions and 21 deletions

View File

@ -70,7 +70,7 @@ export const LibraryState = ({ children }: LibraryStateProps) => {
const [items, setItems] = useState<ILibraryItem[]>([]);
const [templates, setTemplates] = useState<ILibraryItem[]>([]);
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [processing, setProcessing] = useState(false);
const [loadingError, setLoadingError] = useState<ErrorData>(undefined);
const [processingError, setProcessingError] = useState<ErrorData>(undefined);

View File

@ -36,7 +36,7 @@ interface UserProfileStateProps {
export const UserProfileState = ({ children }: UserProfileStateProps) => {
const { users } = useUsers();
const [user, setUser] = useState<IUserProfile | undefined>(undefined);
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [processing, setProcessing] = useState(false);
const [error, setError] = useState<ErrorData>(undefined);
const [errorProcessing, setErrorProcessing] = useState<ErrorData>(undefined);

View File

@ -165,14 +165,14 @@ function DlgEditWordForms({ hideWindow, target, onSave }: DlgEditWordFormsProps)
noHover
title='Определить граммемы'
icon={<IconMoveRight size='1.25rem' className='icon-primary' />}
disabled={textProcessor.loading || !inputText}
disabled={textProcessor.processing || !inputText}
onClick={handleParse}
/>
<MiniButton
noHover
title='Генерировать словоформу'
icon={<IconMoveLeft size='1.25rem' className='icon-primary' />}
disabled={textProcessor.loading || inputGrams.length == 0}
disabled={textProcessor.processing || inputGrams.length == 0}
onClick={handleInflect}
/>
</div>
@ -190,14 +190,14 @@ function DlgEditWordForms({ hideWindow, target, onSave }: DlgEditWordFormsProps)
noHover
title='Внести словоформу'
icon={<IconAccept size='1.5rem' className='icon-green' />}
disabled={textProcessor.loading || !inputText || inputGrams.length == 0}
disabled={textProcessor.processing || !inputText || inputGrams.length == 0}
onClick={handleAddForm}
/>
<MiniButton
noHover
title='Генерировать стандартные словоформы'
icon={<IconMoveDown size='1.5rem' className='icon-primary' />}
disabled={textProcessor.loading || !inputText}
disabled={textProcessor.processing || !inputText}
onClick={handleGenerateLexeme}
/>
</div>
@ -210,7 +210,7 @@ function DlgEditWordForms({ hideWindow, target, onSave }: DlgEditWordFormsProps)
title='Сбросить все словоформы'
className='py-0'
icon={<IconRemove size='1.5rem' className='icon-red' />}
disabled={textProcessor.loading || forms.length === 0}
disabled={textProcessor.processing || forms.length === 0}
onClick={handleResetAll}
/>
</div>

View File

@ -11,7 +11,7 @@ import { RSErrorType } from '@/models/rslang';
import { PARAMETER } from '@/utils/constants';
function useCheckExpression({ schema }: { schema?: IRSForm }) {
const [loading, setLoading] = useState(false);
const [processing, setProcessing] = useState(false);
const [error, setError] = useState<ErrorData>(undefined);
const [parseData, setParseData] = useState<IExpressionParse | undefined>(undefined);
@ -22,7 +22,7 @@ function useCheckExpression({ schema }: { schema?: IRSForm }) {
postCheckExpression(String(schema!.id), {
data: { expression: expression },
showError: true,
setLoading,
setLoading: setProcessing,
onError: setError,
onSuccess: parse => {
if (activeCst) {
@ -34,7 +34,7 @@ function useCheckExpression({ schema }: { schema?: IRSForm }) {
});
}
return { parseData, checkExpression, resetParse, error, setError, loading };
return { parseData, checkExpression, resetParse, error, setError, processing };
}
export default useCheckExpression;

View File

@ -7,7 +7,7 @@ import { ErrorData } from '@/components/info/InfoError';
import { ILexemeData, ITextRequest, ITextResult, IWordFormPlain } from '@/models/language';
function useConceptText() {
const [loading, setLoading] = useState(false);
const [processing, setProcessing] = useState(false);
const [error, setError] = useState<ErrorData>(undefined);
const inflect = useCallback((data: IWordFormPlain, onSuccess: DataCallback<ITextResult>) => {
@ -15,7 +15,7 @@ function useConceptText() {
postInflectText({
data: data,
showError: true,
setLoading,
setLoading: setProcessing,
onError: setError,
onSuccess: data => {
if (onSuccess) onSuccess(data);
@ -28,7 +28,7 @@ function useConceptText() {
postParseText({
data: data,
showError: true,
setLoading,
setLoading: setProcessing,
onError: setError,
onSuccess: data => {
if (onSuccess) onSuccess(data);
@ -41,7 +41,7 @@ function useConceptText() {
postGenerateLexeme({
data: data,
showError: true,
setLoading,
setLoading: setProcessing,
onError: setError,
onSuccess: data => {
if (onSuccess) onSuccess(data);
@ -49,7 +49,7 @@ function useConceptText() {
});
}, []);
return { inflect, parse, generateLexeme, error, setError, loading };
return { inflect, parse, generateLexeme, error, setError, processing };
}
export default useConceptText;

View File

@ -9,7 +9,7 @@ import { OssLoader } from '@/models/OssLoader';
function useOssDetails({ target }: { target?: string }) {
const [schema, setInner] = useState<IOperationSchema | undefined>(undefined);
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<ErrorData>(undefined);
function setSchema(data?: IOperationSchemaData) {

View File

@ -9,7 +9,7 @@ import { RSFormLoader } from '@/models/RSFormLoader';
function useRSFormDetails({ target, version }: { target?: string; version?: string }) {
const [schema, setInnerSchema] = useState<IRSForm | undefined>(undefined);
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<ErrorData>(undefined);
function setSchema(data?: IRSFormData) {

View File

@ -8,7 +8,7 @@ import { IResolutionData } from '@/models/language';
import { IRSForm } from '@/models/rsform';
function useResolveText({ schema }: { schema?: IRSForm }) {
const [loading, setLoading] = useState(false);
const [processing, setProcessing] = useState(false);
const [error, setError] = useState<ErrorData>(undefined);
const [refsData, setRefsData] = useState<IResolutionData | undefined>(undefined);
@ -19,7 +19,7 @@ function useResolveText({ schema }: { schema?: IRSForm }) {
postResolveText(String(schema!.id), {
data: { text: text },
showError: true,
setLoading,
setLoading: setProcessing,
onError: setError,
onSuccess: data => {
setRefsData(data);
@ -28,7 +28,7 @@ function useResolveText({ schema }: { schema?: IRSForm }) {
});
}
return { refsData, resolveText, resetData, error, setError, loading };
return { refsData, resolveText, resetData, error, setError, processing };
}
export default useResolveText;

View File

@ -170,7 +170,7 @@ function EditorRSExpression({
<Overlay position='top-[-0.5rem] pl-[8rem] sm:pl-[4rem] right-1/2 translate-x-1/2 flex'>
<StatusBar
processing={parser.loading}
processing={parser.processing}
isModified={isModified}
constituenta={activeCst}
parseData={parser.parseData}