diff --git a/lib/shared/dm-ops/dm-ops-queue-handler.react.js b/lib/shared/dm-ops/dm-ops-queue-handler.react.js --- a/lib/shared/dm-ops/dm-ops-queue-handler.react.js +++ b/lib/shared/dm-ops/dm-ops-queue-handler.react.js @@ -155,20 +155,25 @@ }, [dispatch, enqueue, messageInfos, queuedMessageOperations]); const entryInfos = useSelector(entryInfoSelector); - const prevEntryInfosRef = React.useRef({}); const queuedEntryOperations = useSelector( state => state.queuedDMOperations.entryQueue, ); - React.useEffect(() => { - const prevEntryInfos = prevEntryInfosRef.current; - prevEntryInfosRef.current = entryInfos; + const runningEntryOperations = React.useRef>(new Set()); + React.useEffect(() => { for (const entryID in queuedEntryOperations) { - if (!entryInfos[entryID] || prevEntryInfos[entryID]) { + if (!entryInfos[entryID]) { + continue; + } + + if (runningEntryOperations.current.has(entryID)) { continue; } + + runningEntryOperations.current.add(entryID); + enqueue([ ...queuedEntryOperations[entryID].map(item => ({ type: 'operation', @@ -183,6 +188,10 @@ }, }, }, + { + type: 'function', + itemFunction: () => runningEntryOperations.current.delete(entryID), + }, ]); } }, [dispatch, enqueue, entryInfos, queuedEntryOperations]);