Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3350115
D13814.id45462.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
730 B
Referenced Files
None
Subscribers
None
D13814.id45462.diff
View Options
diff --git a/lib/hooks/actions-queue.js b/lib/hooks/actions-queue.js
--- a/lib/hooks/actions-queue.js
+++ b/lib/hooks/actions-queue.js
@@ -8,6 +8,7 @@
function useActionsQueue<T>(
performAction: (item: T) => mixed | Promise<mixed>,
+ canProcess: boolean = true,
): MessageQueueHook<T> {
const [queue, setQueue] = React.useState<$ReadOnlyArray<T>>([]);
const isProcessing = React.useRef(false);
@@ -32,11 +33,11 @@
);
React.useEffect(() => {
- if (isProcessing.current || queue.length === 0) {
+ if (isProcessing.current || queue.length === 0 || !canProcess) {
return;
}
void process(queue[0]);
- }, [process, queue]);
+ }, [process, queue, canProcess]);
return { enqueue };
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 8:50 PM (16 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2572397
Default Alt Text
D13814.id45462.diff (730 B)
Attached To
Mode
D13814: [lib] Add `canProcess` parameter to `useActionsQueue`
Attached
Detach File
Event Timeline
Log In to Comment