MediaGallery: Load only once with no attachments to show
This commit is contained in:
parent
1d199cfff6
commit
bc6831a1d2
2 changed files with 19 additions and 5 deletions
|
@ -160,12 +160,24 @@ export function MediaGallery({
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (media.length > 0 || documents.length > 0) {
|
if (
|
||||||
|
media.length > 0 ||
|
||||||
|
documents.length > 0 ||
|
||||||
|
haveOldestDocument ||
|
||||||
|
haveOldestMedia
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
initialLoad(conversationId);
|
initialLoad(conversationId);
|
||||||
loadingRef.current = true;
|
loadingRef.current = true;
|
||||||
}, [conversationId, initialLoad, media, documents]);
|
}, [
|
||||||
|
conversationId,
|
||||||
|
haveOldestDocument,
|
||||||
|
haveOldestMedia,
|
||||||
|
initialLoad,
|
||||||
|
media,
|
||||||
|
documents,
|
||||||
|
]);
|
||||||
|
|
||||||
const previousLoading = usePrevious(loading, loading);
|
const previousLoading = usePrevious(loading, loading);
|
||||||
if (previousLoading && !loading) {
|
if (previousLoading && !loading) {
|
||||||
|
|
|
@ -410,12 +410,14 @@ export function reducer(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.type === INITIAL_LOAD) {
|
if (action.type === INITIAL_LOAD) {
|
||||||
|
const { payload } = action;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
loading: false,
|
loading: false,
|
||||||
...action.payload,
|
...payload,
|
||||||
haveOldestDocument: false,
|
haveOldestMedia: payload.media.length === 0,
|
||||||
haveOldestMedia: false,
|
haveOldestDocument: payload.documents.length === 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue