disable exhaustive-dep bc i dont want it to change when baord changes

This commit is contained in:
Mary Hipp 2023-07-14 13:45:53 -04:00
parent 067d5b22b2
commit 6be3da4e71

View File

@ -73,19 +73,13 @@ const GalleryImageGrid = () => {
setLimit(INITIAL_IMAGE_LIMIT); setLimit(INITIAL_IMAGE_LIMIT);
}, [selectedBoardId]); }, [selectedBoardId]);
const BASE_QUERY = useMemo(() => { const { data: imageListResponse, isLoading: isLoading } = useListImagesQuery({
return { categories: galleryView === 'images' ? IMAGE_CATEGORIES : ASSETS_CATEGORIES,
categories:
galleryView === 'images' ? IMAGE_CATEGORIES : ASSETS_CATEGORIES,
is_intermediate: false, is_intermediate: false,
offset: 0, offset: 0,
limit: INITIAL_IMAGE_LIMIT, limit: INITIAL_IMAGE_LIMIT,
...(selectedBoardId === 'all' ? {} : { board_id: selectedBoardId }), ...(selectedBoardId === 'all' ? {} : { board_id: selectedBoardId }),
}; });
}, [galleryView, selectedBoardId]);
const { data: imageListResponse, isLoading: isLoading } =
useListImagesQuery(BASE_QUERY);
const { data: paginatedData } = useListImagesQuery( const { data: paginatedData } = useListImagesQuery(
{ {
@ -108,7 +102,14 @@ const GalleryImageGrid = () => {
dispatch( dispatch(
imagesApi.util.updateQueryData( imagesApi.util.updateQueryData(
'listImages', 'listImages',
BASE_QUERY, {
categories:
galleryView === 'images' ? IMAGE_CATEGORIES : ASSETS_CATEGORIES,
is_intermediate: false,
offset: 0,
limit: INITIAL_IMAGE_LIMIT,
...(selectedBoardId === 'all' ? {} : { board_id: selectedBoardId }),
},
(draftPosts) => { (draftPosts) => {
paginatedData.items.forEach((item) => { paginatedData.items.forEach((item) => {
draftPosts.items.push(item); draftPosts.items.push(item);
@ -117,7 +118,8 @@ const GalleryImageGrid = () => {
) )
); );
} }
}, [paginatedData, dispatch, BASE_QUERY]); //eslint-disable-next-line
}, [paginatedData, dispatch]);
const areMoreAvailable = useMemo(() => { const areMoreAvailable = useMemo(() => {
if (imageListResponse?.total) { if (imageListResponse?.total) {