Revert "nicolium: try to improve loading time"

This reverts commit 1343d2888f.

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-03-19 17:47:26 +01:00
parent e6f1311562
commit 9ffe24b9af
2 changed files with 9 additions and 20 deletions

View File

@ -14,23 +14,16 @@ const getHost = () => {
}
};
const doFetchInstance = async () => {
const client = getClient();
const instance = await client.instance.getInstance();
useInstanceStore.getState().actions.loadInstance(instance);
useComposeStore.getState().actions.importDefaultContentType(instance);
};
const fetchInstance = async () => {
const { fetched, instanceFetchFailed } = useInstanceStore.getState();
if (fetched || (instanceFetchFailed && !getAuthUserUrl())) return;
try {
const client = getClient();
const instance = await client.instance.getInstance();
const promise = doFetchInstance().catch((error) => {
useInstanceStore.getState().actions.loadInstance(instance);
useComposeStore.getState().actions.importDefaultContentType(instance);
} catch (error) {
useInstanceStore.getState().actions.instanceFetchFailed(error);
});
if (!fetched && !getAuthUserUrl()) await promise;
}
};
const checkIfStandalone = () =>
@ -38,11 +31,9 @@ const checkIfStandalone = () =>
.then(({ ok, headers }) => {
const isOk = ok && !!headers.get('content-type')?.includes('application/json');
useInstanceStore.getState().actions.setInstanceFetchFailed(!isOk);
return !isOk;
})
.catch((err) => {
useInstanceStore.getState().actions.setInstanceFetchFailed(!err.response?.ok);
return true;
});
export { getHost, fetchInstance, checkIfStandalone };

View File

@ -42,12 +42,10 @@ const NicoliumLoad: React.FC<INicoliumLoad> = ({ children }) => {
useEffect(() => {
/** Load initial data from the backend */
const loadInitial = async () => {
const standaloneCheck = checkIfStandalone();
checkIfStandalone();
// Await for authenticated fetch
await fetchMe();
// Wait for standalone detection before proceeding
await standaloneCheck;
// Await for feature detection (skipped if already fetched or standalone)
// Await for feature detection
await fetchInstance();
// Await for configuration
await loadFrontendConfig();