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:
@ -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 };
|
||||
|
||||
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user