mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Fix context loading semantics
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:
parent
c430a0132c
commit
122bf4fcc1
|
@ -70,7 +70,7 @@ export const LibraryState = ({ children }: LibraryStateProps) => {
|
||||||
|
|
||||||
const [items, setItems] = useState<ILibraryItem[]>([]);
|
const [items, setItems] = useState<ILibraryItem[]>([]);
|
||||||
const [templates, setTemplates] = useState<ILibraryItem[]>([]);
|
const [templates, setTemplates] = useState<ILibraryItem[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(true);
|
||||||
const [processing, setProcessing] = useState(false);
|
const [processing, setProcessing] = useState(false);
|
||||||
const [loadingError, setLoadingError] = useState<ErrorData>(undefined);
|
const [loadingError, setLoadingError] = useState<ErrorData>(undefined);
|
||||||
const [processingError, setProcessingError] = useState<ErrorData>(undefined);
|
const [processingError, setProcessingError] = useState<ErrorData>(undefined);
|
||||||
|
|
|
@ -36,7 +36,7 @@ interface UserProfileStateProps {
|
||||||
export const UserProfileState = ({ children }: UserProfileStateProps) => {
|
export const UserProfileState = ({ children }: UserProfileStateProps) => {
|
||||||
const { users } = useUsers();
|
const { users } = useUsers();
|
||||||
const [user, setUser] = useState<IUserProfile | undefined>(undefined);
|
const [user, setUser] = useState<IUserProfile | undefined>(undefined);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(true);
|
||||||
const [processing, setProcessing] = useState(false);
|
const [processing, setProcessing] = useState(false);
|
||||||
const [error, setError] = useState<ErrorData>(undefined);
|
const [error, setError] = useState<ErrorData>(undefined);
|
||||||
const [errorProcessing, setErrorProcessing] = useState<ErrorData>(undefined);
|
const [errorProcessing, setErrorProcessing] = useState<ErrorData>(undefined);
|
||||||
|
|
|
@ -165,14 +165,14 @@ function DlgEditWordForms({ hideWindow, target, onSave }: DlgEditWordFormsProps)
|
||||||
noHover
|
noHover
|
||||||
title='Определить граммемы'
|
title='Определить граммемы'
|
||||||
icon={<IconMoveRight size='1.25rem' className='icon-primary' />}
|
icon={<IconMoveRight size='1.25rem' className='icon-primary' />}
|
||||||
disabled={textProcessor.loading || !inputText}
|
disabled={textProcessor.processing || !inputText}
|
||||||
onClick={handleParse}
|
onClick={handleParse}
|
||||||
/>
|
/>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
noHover
|
noHover
|
||||||
title='Генерировать словоформу'
|
title='Генерировать словоформу'
|
||||||
icon={<IconMoveLeft size='1.25rem' className='icon-primary' />}
|
icon={<IconMoveLeft size='1.25rem' className='icon-primary' />}
|
||||||
disabled={textProcessor.loading || inputGrams.length == 0}
|
disabled={textProcessor.processing || inputGrams.length == 0}
|
||||||
onClick={handleInflect}
|
onClick={handleInflect}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -190,14 +190,14 @@ function DlgEditWordForms({ hideWindow, target, onSave }: DlgEditWordFormsProps)
|
||||||
noHover
|
noHover
|
||||||
title='Внести словоформу'
|
title='Внести словоформу'
|
||||||
icon={<IconAccept size='1.5rem' className='icon-green' />}
|
icon={<IconAccept size='1.5rem' className='icon-green' />}
|
||||||
disabled={textProcessor.loading || !inputText || inputGrams.length == 0}
|
disabled={textProcessor.processing || !inputText || inputGrams.length == 0}
|
||||||
onClick={handleAddForm}
|
onClick={handleAddForm}
|
||||||
/>
|
/>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
noHover
|
noHover
|
||||||
title='Генерировать стандартные словоформы'
|
title='Генерировать стандартные словоформы'
|
||||||
icon={<IconMoveDown size='1.5rem' className='icon-primary' />}
|
icon={<IconMoveDown size='1.5rem' className='icon-primary' />}
|
||||||
disabled={textProcessor.loading || !inputText}
|
disabled={textProcessor.processing || !inputText}
|
||||||
onClick={handleGenerateLexeme}
|
onClick={handleGenerateLexeme}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -210,7 +210,7 @@ function DlgEditWordForms({ hideWindow, target, onSave }: DlgEditWordFormsProps)
|
||||||
title='Сбросить все словоформы'
|
title='Сбросить все словоформы'
|
||||||
className='py-0'
|
className='py-0'
|
||||||
icon={<IconRemove size='1.5rem' className='icon-red' />}
|
icon={<IconRemove size='1.5rem' className='icon-red' />}
|
||||||
disabled={textProcessor.loading || forms.length === 0}
|
disabled={textProcessor.processing || forms.length === 0}
|
||||||
onClick={handleResetAll}
|
onClick={handleResetAll}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { RSErrorType } from '@/models/rslang';
|
||||||
import { PARAMETER } from '@/utils/constants';
|
import { PARAMETER } from '@/utils/constants';
|
||||||
|
|
||||||
function useCheckExpression({ schema }: { schema?: IRSForm }) {
|
function useCheckExpression({ schema }: { schema?: IRSForm }) {
|
||||||
const [loading, setLoading] = useState(false);
|
const [processing, setProcessing] = useState(false);
|
||||||
const [error, setError] = useState<ErrorData>(undefined);
|
const [error, setError] = useState<ErrorData>(undefined);
|
||||||
const [parseData, setParseData] = useState<IExpressionParse | undefined>(undefined);
|
const [parseData, setParseData] = useState<IExpressionParse | undefined>(undefined);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ function useCheckExpression({ schema }: { schema?: IRSForm }) {
|
||||||
postCheckExpression(String(schema!.id), {
|
postCheckExpression(String(schema!.id), {
|
||||||
data: { expression: expression },
|
data: { expression: expression },
|
||||||
showError: true,
|
showError: true,
|
||||||
setLoading,
|
setLoading: setProcessing,
|
||||||
onError: setError,
|
onError: setError,
|
||||||
onSuccess: parse => {
|
onSuccess: parse => {
|
||||||
if (activeCst) {
|
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;
|
export default useCheckExpression;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ErrorData } from '@/components/info/InfoError';
|
||||||
import { ILexemeData, ITextRequest, ITextResult, IWordFormPlain } from '@/models/language';
|
import { ILexemeData, ITextRequest, ITextResult, IWordFormPlain } from '@/models/language';
|
||||||
|
|
||||||
function useConceptText() {
|
function useConceptText() {
|
||||||
const [loading, setLoading] = useState(false);
|
const [processing, setProcessing] = useState(false);
|
||||||
const [error, setError] = useState<ErrorData>(undefined);
|
const [error, setError] = useState<ErrorData>(undefined);
|
||||||
|
|
||||||
const inflect = useCallback((data: IWordFormPlain, onSuccess: DataCallback<ITextResult>) => {
|
const inflect = useCallback((data: IWordFormPlain, onSuccess: DataCallback<ITextResult>) => {
|
||||||
|
@ -15,7 +15,7 @@ function useConceptText() {
|
||||||
postInflectText({
|
postInflectText({
|
||||||
data: data,
|
data: data,
|
||||||
showError: true,
|
showError: true,
|
||||||
setLoading,
|
setLoading: setProcessing,
|
||||||
onError: setError,
|
onError: setError,
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
if (onSuccess) onSuccess(data);
|
if (onSuccess) onSuccess(data);
|
||||||
|
@ -28,7 +28,7 @@ function useConceptText() {
|
||||||
postParseText({
|
postParseText({
|
||||||
data: data,
|
data: data,
|
||||||
showError: true,
|
showError: true,
|
||||||
setLoading,
|
setLoading: setProcessing,
|
||||||
onError: setError,
|
onError: setError,
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
if (onSuccess) onSuccess(data);
|
if (onSuccess) onSuccess(data);
|
||||||
|
@ -41,7 +41,7 @@ function useConceptText() {
|
||||||
postGenerateLexeme({
|
postGenerateLexeme({
|
||||||
data: data,
|
data: data,
|
||||||
showError: true,
|
showError: true,
|
||||||
setLoading,
|
setLoading: setProcessing,
|
||||||
onError: setError,
|
onError: setError,
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
if (onSuccess) 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;
|
export default useConceptText;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { OssLoader } from '@/models/OssLoader';
|
||||||
|
|
||||||
function useOssDetails({ target }: { target?: string }) {
|
function useOssDetails({ target }: { target?: string }) {
|
||||||
const [schema, setInner] = useState<IOperationSchema | undefined>(undefined);
|
const [schema, setInner] = useState<IOperationSchema | undefined>(undefined);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<ErrorData>(undefined);
|
const [error, setError] = useState<ErrorData>(undefined);
|
||||||
|
|
||||||
function setSchema(data?: IOperationSchemaData) {
|
function setSchema(data?: IOperationSchemaData) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { RSFormLoader } from '@/models/RSFormLoader';
|
||||||
|
|
||||||
function useRSFormDetails({ target, version }: { target?: string; version?: string }) {
|
function useRSFormDetails({ target, version }: { target?: string; version?: string }) {
|
||||||
const [schema, setInnerSchema] = useState<IRSForm | undefined>(undefined);
|
const [schema, setInnerSchema] = useState<IRSForm | undefined>(undefined);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<ErrorData>(undefined);
|
const [error, setError] = useState<ErrorData>(undefined);
|
||||||
|
|
||||||
function setSchema(data?: IRSFormData) {
|
function setSchema(data?: IRSFormData) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { IResolutionData } from '@/models/language';
|
||||||
import { IRSForm } from '@/models/rsform';
|
import { IRSForm } from '@/models/rsform';
|
||||||
|
|
||||||
function useResolveText({ schema }: { schema?: IRSForm }) {
|
function useResolveText({ schema }: { schema?: IRSForm }) {
|
||||||
const [loading, setLoading] = useState(false);
|
const [processing, setProcessing] = useState(false);
|
||||||
const [error, setError] = useState<ErrorData>(undefined);
|
const [error, setError] = useState<ErrorData>(undefined);
|
||||||
const [refsData, setRefsData] = useState<IResolutionData | undefined>(undefined);
|
const [refsData, setRefsData] = useState<IResolutionData | undefined>(undefined);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ function useResolveText({ schema }: { schema?: IRSForm }) {
|
||||||
postResolveText(String(schema!.id), {
|
postResolveText(String(schema!.id), {
|
||||||
data: { text: text },
|
data: { text: text },
|
||||||
showError: true,
|
showError: true,
|
||||||
setLoading,
|
setLoading: setProcessing,
|
||||||
onError: setError,
|
onError: setError,
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
setRefsData(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;
|
export default useResolveText;
|
||||||
|
|
|
@ -170,7 +170,7 @@ function EditorRSExpression({
|
||||||
|
|
||||||
<Overlay position='top-[-0.5rem] pl-[8rem] sm:pl-[4rem] right-1/2 translate-x-1/2 flex'>
|
<Overlay position='top-[-0.5rem] pl-[8rem] sm:pl-[4rem] right-1/2 translate-x-1/2 flex'>
|
||||||
<StatusBar
|
<StatusBar
|
||||||
processing={parser.loading}
|
processing={parser.processing}
|
||||||
isModified={isModified}
|
isModified={isModified}
|
||||||
constituenta={activeCst}
|
constituenta={activeCst}
|
||||||
parseData={parser.parseData}
|
parseData={parser.parseData}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user