Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3168825
D13861.id45583.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13861.id45583.diff
View Options
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
@@ -63,12 +63,13 @@
}, [prune]);
const threadInfos = useSelector(threadInfoSelector);
- const prevThreadInfosRef = React.useRef({});
const queuedThreadOperations = useSelector(
state => state.queuedDMOperations.threadQueue,
);
+ const runningThreadOperations = React.useRef<Set<string>>(new Set());
+
const processDMOperation = useProcessDMOperation();
const processItem = React.useCallback(
@@ -96,13 +97,17 @@
const { enqueue } = useActionsQueue(processItem);
React.useEffect(() => {
- const prevThreadInfos = prevThreadInfosRef.current;
- prevThreadInfosRef.current = threadInfos;
-
for (const threadID in queuedThreadOperations) {
- if (!threadInfos[threadID] || prevThreadInfos[threadID]) {
+ if (!threadInfos[threadID]) {
+ continue;
+ }
+
+ if (runningThreadOperations.current.has(threadID)) {
continue;
}
+
+ runningThreadOperations.current.add(threadID);
+
enqueue([
...queuedThreadOperations[threadID].map(item => ({
type: 'operation',
@@ -117,6 +122,10 @@
},
},
},
+ {
+ type: 'function',
+ itemFunction: () => runningThreadOperations.current.delete(threadID),
+ },
]);
}
}, [dispatch, enqueue, queuedThreadOperations, threadInfos]);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 8:39 AM (21 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2440501
Default Alt Text
D13861.id45583.diff (1 KB)
Attached To
Mode
D13861: [lib] Refactor threads queue in DMOpsQueueHandler
Attached
Detach File
Event Timeline
Log In to Comment