chore(ui): lint/format

This commit is contained in:
psychedelicious 2023-08-08 12:49:54 +10:00
parent 734a9e4271
commit 57e8ec9488

View File

@ -170,11 +170,11 @@ export const imagesApi = api.injectEndpoints({
}, },
invalidatesTags: (result, error, { imageDTOs }) => { invalidatesTags: (result, error, { imageDTOs }) => {
// for now, assume bulk delete is all on one board // for now, assume bulk delete is all on one board
const boardId = imageDTOs[0]?.board_id const boardId = imageDTOs[0]?.board_id;
return [ return [
{ type: 'BoardImagesTotal', id: boardId ?? 'none' }, { type: 'BoardImagesTotal', id: boardId ?? 'none' },
{ type: 'BoardAssetsTotal', id: boardId ?? 'none' }, { type: 'BoardAssetsTotal', id: boardId ?? 'none' },
] ];
}, },
async onQueryStarted({ imageDTOs }, { dispatch, queryFulfilled }) { async onQueryStarted({ imageDTOs }, { dispatch, queryFulfilled }) {
/** /**
@ -912,7 +912,7 @@ export const imagesApi = api.injectEndpoints({
// update the no_board totals // update the no_board totals
{ type: 'BoardImagesTotal', id: 'none' }, { type: 'BoardImagesTotal', id: 'none' },
{ type: 'BoardAssetsTotal', id: 'none' }, { type: 'BoardAssetsTotal', id: 'none' },
] ];
}, },
async onQueryStarted( async onQueryStarted(
{ board_id: new_board_id, imageDTOs }, { board_id: new_board_id, imageDTOs },
@ -969,7 +969,6 @@ export const imagesApi = api.injectEndpoints({
queryArgs queryArgs
)(getState()); )(getState());
const { data: previousTotal } = IMAGE_CATEGORIES.includes( const { data: previousTotal } = IMAGE_CATEGORIES.includes(
imageDTO.image_category imageDTO.image_category
) )
@ -981,15 +980,15 @@ export const imagesApi = api.injectEndpoints({
)(getState()); )(getState());
const isCacheFullyPopulated = const isCacheFullyPopulated =
currentCache.data && currentCache.data.ids.length >= (previousTotal ?? 0); currentCache.data &&
currentCache.data.ids.length >= (previousTotal ?? 0);
const isInDateRange = (previousTotal || 0) >= IMAGE_LIMIT ? getIsImageInDateRange( const isInDateRange =
currentCache.data, (previousTotal || 0) >= IMAGE_LIMIT
imageDTO ? getIsImageInDateRange(currentCache.data, imageDTO)
) : true; : true;
if (isCacheFullyPopulated || isInDateRange) { if (isCacheFullyPopulated || isInDateRange) {
console.log("upserting")
// *upsert* to $cache // *upsert* to $cache
dispatch( dispatch(
imagesApi.util.updateQueryData( imagesApi.util.updateQueryData(
@ -1114,10 +1113,10 @@ export const imagesApi = api.injectEndpoints({
const isCacheFullyPopulated = const isCacheFullyPopulated =
currentCache.data && currentCache.data.ids.length >= (total ?? 0); currentCache.data && currentCache.data.ids.length >= (total ?? 0);
const isInDateRange = (total || 0) >= IMAGE_LIMIT ? getIsImageInDateRange( const isInDateRange =
currentCache.data, (total || 0) >= IMAGE_LIMIT
imageDTO ? getIsImageInDateRange(currentCache.data, imageDTO)
) : true; : true;
if (isCacheFullyPopulated || isInDateRange) { if (isCacheFullyPopulated || isInDateRange) {
// *upsert* to $cache // *upsert* to $cache
@ -1128,7 +1127,7 @@ export const imagesApi = api.injectEndpoints({
(draft) => { (draft) => {
imagesAdapter.upsertOne(draft, { imagesAdapter.upsertOne(draft, {
...imageDTO, ...imageDTO,
board_id: "none", board_id: 'none',
}); });
} }
) )