Reorder fetch requests/useEffect
Build and publish docker image snapshot / build-and-publish (push) Successful in 1m9s
Details
Build and publish docker image snapshot / build-and-publish (push) Successful in 1m9s
Details
directories need to be loaded first as it is a main element that never changes and is always displayed folder previews are shown above images and should therefore be loaded before images
This commit is contained in:
parent
4794f4e62b
commit
111dee8e7e
|
|
@ -35,11 +35,30 @@ function ImageGalleryLayout() {
|
||||||
setDrawerOpen(!drawerOpen);
|
setDrawerOpen(!drawerOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch("/directories", {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((data) => setFolders(data));
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFoldersPreview(undefined);
|
setFoldersPreview(undefined);
|
||||||
setImages([]);
|
setImages([]);
|
||||||
setError(false);
|
setError(false);
|
||||||
setImagesLoaded(false);
|
setImagesLoaded(false);
|
||||||
|
fetch(`/folderspreview${location.pathname}`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((data) => {
|
||||||
|
setFoldersPreview(data);
|
||||||
|
});
|
||||||
fetch(`/images${location.pathname}`, {
|
fetch(`/images${location.pathname}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
|
|
@ -58,27 +77,8 @@ function ImageGalleryLayout() {
|
||||||
setImagesLoaded(true);
|
setImagesLoaded(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fetch(`/folderspreview${location.pathname}`, {
|
|
||||||
headers: {
|
|
||||||
Accept: "application/json",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((data) => {
|
|
||||||
setFoldersPreview(data);
|
|
||||||
});
|
|
||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
fetch("/directories", {
|
|
||||||
headers: {
|
|
||||||
Accept: "application/json",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((data) => setFolders(data));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue