dev #21
@ -40,7 +40,6 @@ export function useCoffeePictures(coffeeId?: string) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!coffeeId) {
|
if (!coffeeId) {
|
||||||
setPictureUrls([]);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,9 +50,10 @@ export function useCoffeePictures(coffeeId?: string) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let isCancelled = false;
|
let isCancelled = false;
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
const loadPictures = async () => {
|
const loadPictures = async () => {
|
||||||
|
if (!isCancelled) setLoading(true);
|
||||||
|
|
||||||
for (const url of candidateUrls) {
|
for (const url of candidateUrls) {
|
||||||
try {
|
try {
|
||||||
const response = await authFetch(url, {
|
const response = await authFetch(url, {
|
||||||
@ -105,5 +105,8 @@ export function useCoffeePictures(coffeeId?: string) {
|
|||||||
};
|
};
|
||||||
}, [coffeeId]);
|
}, [coffeeId]);
|
||||||
|
|
||||||
return { pictureUrls, loading };
|
return {
|
||||||
|
pictureUrls: coffeeId ? pictureUrls : [],
|
||||||
|
loading: coffeeId ? loading : false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user