Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32197821
D13288.1765104171.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D13288.1765104171.diff
View Options
diff --git a/lib/shared/dm-ops/process-dm-ops.js b/lib/shared/dm-ops/process-dm-ops.js
--- a/lib/shared/dm-ops/process-dm-ops.js
+++ b/lib/shared/dm-ops/process-dm-ops.js
@@ -311,18 +311,31 @@
const dispatchActionPromise = useDispatchActionPromise();
const { getDMOpsSendingPromise } = usePeerToPeerCommunication();
- return React.useCallback(
- async (dmOperationSpecification: OutboundDMOperationSpecification) => {
+ const [operations, setOperations] = React.useState<
+ [
+ OutboundDMOperationSpecification,
+ (input: any) => void,
+ (input: any) => void,
+ ][],
+ >([]);
+
+ React.useEffect(() => {
+ const handleOperations = async () => {
+ const [queueTop] = operations;
+ setOperations(oldOperations => {
+ const [, ...rest] = oldOperations;
+ return rest;
+ });
+ const [operation, resolve] = queueTop;
const { promise, dmOpID } = getDMOpsSendingPromise();
- await processDMOps(dmOperationSpecification, dmOpID);
+ await processDMOps(operation, dmOpID);
if (
- dmOperationSpecification.type ===
- dmOperationSpecificationTypes.OUTBOUND &&
- !dmOpSpecs[dmOperationSpecification.op.type].supportsAutoRetry &&
- dmOperationSpecification.op.messageID
+ operation.type === dmOperationSpecificationTypes.OUTBOUND &&
+ !dmOpSpecs[operation.op.type].supportsAutoRetry &&
+ operation.op.messageID
) {
- const messageID: string = dmOperationSpecification.op.messageID;
+ const messageID: string = operation.op.messageID;
const sendingPromise: Promise<SendDMOpsSuccessPayload> = (async () => {
const outboundP2PMessageIDs = await promise;
@@ -332,7 +345,7 @@
};
})();
- void dispatchActionPromise(
+ await dispatchActionPromise(
sendDMActionTypes,
sendingPromise,
undefined,
@@ -341,8 +354,25 @@
},
);
}
+ resolve();
+ };
+ if (operations.length > 0) {
+ void handleOperations();
+ }
+ }, [dispatchActionPromise, getDMOpsSendingPromise, operations, processDMOps]);
+
+ return React.useCallback(
+ async (dmOperationSpecification: OutboundDMOperationSpecification) => {
+ const promise = new Promise<void>((resolve, reject) => {
+ setOperations(oldOperations => [
+ ...oldOperations,
+ [dmOperationSpecification, resolve, reject],
+ ]);
+ });
+
+ return promise;
},
- [dispatchActionPromise, getDMOpsSendingPromise, processDMOps],
+ [],
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 10:42 AM (7 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842568
Default Alt Text
D13288.1765104171.diff (2 KB)
Attached To
Mode
D13288: [lib] Fix useProcessAndSendDMOperation
Attached
Detach File
Event Timeline
Log In to Comment