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 @@ -318,16 +318,34 @@ utilities, ); - const notificationsCreationData = await dmOpSpecs[ - op.type - ].notificationsCreationData?.(op, utilities); + const spec = dmOpSpecs[op.type]; + + const notificationsCreationDataPromise: Promise = + (async () => { + if (!spec?.notificationsCreationData) { + return null; + } + return await spec.notificationsCreationData(op, utilities); + })(); + + const [{ rawMessageInfos, updateInfos }, notificationsCreationData] = + await Promise.all([ + dmOpSpecs[op.type].processDMOperation(op, utilities), + notificationsCreationDataPromise, + ]); + + const newUpdateInfos = getThreadUpdatesForNewMessages( + rawMessageInfos, + updateInfos, + utilities, + ); dispatchWithMetadata( { type: processDMOpsActionType, payload: { rawMessageInfos: [], - updateInfos: [], + updateInfos: newUpdateInfos, outboundP2PMessages, composableMessageID, notificationsCreationData,