diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/tables.ts b/specifyweb/frontend/js_src/lib/components/DataModel/tables.ts index 32d4bfbafb4..1c85b563a2d 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/tables.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/tables.ts @@ -61,12 +61,21 @@ const processFields = ( let schemaLocalization: IR = undefined!; const fetchSchemaLocalization = f.store(async () => import('../Preferences/userPreferences').then(async ({ userPreferences }) => - load>( - formatUrl('/context/schema_localization.json', { - lang: userPreferences.get('form', 'schema', 'language'), - }), - 'application/json' - ) + // Preferences are fetched independently of the initial context. Reading + // the schema language before that fetch completes can request the default + // language, and f.store() would then keep that localization for the life + // of the page. + userPreferences + .fetch() + .catch(() => undefined) + .then(() => + load>( + formatUrl('/context/schema_localization.json', { + lang: userPreferences.get('form', 'schema', 'language'), + }), + 'application/json' + ) + ) ) ); export const getSchemaLocalization = (): IR => diff --git a/specifyweb/frontend/js_src/lib/components/SchemaConfig/Layout.tsx b/specifyweb/frontend/js_src/lib/components/SchemaConfig/Layout.tsx index ac53a147a8d..fd7b08024c5 100644 --- a/specifyweb/frontend/js_src/lib/components/SchemaConfig/Layout.tsx +++ b/specifyweb/frontend/js_src/lib/components/SchemaConfig/Layout.tsx @@ -24,7 +24,7 @@ import { useSchemaConfig, } from './Store'; import { dialogIcons } from '../Atoms/Icons'; -import { raise } from '../Errors/Crash'; +import { raise } from '../Errors/Crash'; export function SchemaConfigLayout(): JSX.Element { const schemaData = useOutletContext(); @@ -94,20 +94,30 @@ function SchemaConfigLayoutContent(): JSX.Element { method: 'POST', headers: { Accept: 'application/json' }, body: { schema, language: rawLanguage }, - expectedErrors: [400, 500, 504] + expectedErrors: [400, 500, 504], }) ) .then( (response) => { - setImportStatus(response.status); - if (response.status !== 200) - raise({name: schemaText.importSchemaError({schemaConfig: schemaText.schemaConfig()}), message: - response.status === 504 ? schemaText.importSchemaErrorTimeout({schemaConfig: schemaText.schemaConfig()}) : - response.status === 400 ? schemaText.importSchemaErrorBadRequest({schemaConfig: schemaText.schemaConfig()}) : - schemaText.importSchemaErrorInternalError() - }) - }, - (err) => raise(err) + setImportStatus(response.status); + if (response.status !== 200) + raise({ + name: schemaText.importSchemaError({ + schemaConfig: schemaText.schemaConfig(), + }), + message: + response.status === 504 + ? schemaText.importSchemaErrorTimeout({ + schemaConfig: schemaText.schemaConfig(), + }) + : response.status === 400 + ? schemaText.importSchemaErrorBadRequest({ + schemaConfig: schemaText.schemaConfig(), + }) + : schemaText.importSchemaErrorInternalError(), + }); + }, + (err) => raise(err) ) ); };