fix(ui): remove extraneous cache update

This commit is contained in:
psychedelicious 2023-10-09 18:46:37 +11:00
parent ca95a3bd0d
commit 1f751f8c21

View File

@ -12,14 +12,15 @@ export const addSocketQueueItemStatusChangedEventListener = () => {
effect: async (action, { dispatch }) => { effect: async (action, { dispatch }) => {
const log = logger('socketio'); const log = logger('socketio');
// we've got new status for the queue item, batch and queue
const { queue_item, batch_status, queue_status } = action.payload.data; const { queue_item, batch_status, queue_status } = action.payload.data;
log.debug( log.debug(
action.payload, action.payload,
`Queue item ${queue_item.item_id} status updated: ${queue_item.status}` `Queue item ${queue_item.item_id} status updated: ${queue_item.status}`
); );
dispatch(appSocketQueueItemStatusChanged(action.payload));
// Update this specific queue item in the list of queue items (this is the queue item DTO, without the session)
dispatch( dispatch(
queueApi.util.updateQueryData('listQueueItems', undefined, (draft) => { queueApi.util.updateQueryData('listQueueItems', undefined, (draft) => {
queueItemsAdapter.updateOne(draft, { queueItemsAdapter.updateOne(draft, {
@ -29,11 +30,7 @@ export const addSocketQueueItemStatusChangedEventListener = () => {
}) })
); );
dispatch( // Update the queue status (we do not get the processor status here)
queueApi.util.updateQueryData('getQueueStatus', undefined, (draft) => {
Object.assign(draft.queue, queue_status);
})
);
dispatch( dispatch(
queueApi.util.updateQueryData('getQueueStatus', undefined, (draft) => { queueApi.util.updateQueryData('getQueueStatus', undefined, (draft) => {
if (!draft) { if (!draft) {
@ -43,6 +40,7 @@ export const addSocketQueueItemStatusChangedEventListener = () => {
}) })
); );
// Update the batch status
dispatch( dispatch(
queueApi.util.updateQueryData( queueApi.util.updateQueryData(
'getBatchStatus', 'getBatchStatus',
@ -51,6 +49,7 @@ export const addSocketQueueItemStatusChangedEventListener = () => {
) )
); );
// Update the queue item status (this is the full queue item, including the session)
dispatch( dispatch(
queueApi.util.updateQueryData( queueApi.util.updateQueryData(
'getQueueItem', 'getQueueItem',
@ -64,6 +63,8 @@ export const addSocketQueueItemStatusChangedEventListener = () => {
) )
); );
// Invalidate caches for things we cannot update
// TODO: technically, we could possibly update the current session queue item, but feels safer to just request it again
dispatch( dispatch(
queueApi.util.invalidateTags([ queueApi.util.invalidateTags([
'CurrentSessionQueueItem', 'CurrentSessionQueueItem',
@ -71,6 +72,9 @@ export const addSocketQueueItemStatusChangedEventListener = () => {
'InvocationCacheStatus', 'InvocationCacheStatus',
]) ])
); );
// Pass the event along
dispatch(appSocketQueueItemStatusChanged(action.payload));
}, },
}); });
}; };