From 887af9313d3c1be70ebc94a161b5cd323314b1ab Mon Sep 17 00:00:00 2001 From: xsanm Date: Mon, 23 Sep 2024 12:35:34 +0200 Subject: [PATCH] [lib] implement reply count for composable DM messages Summary: [ENG-9273](https://linear.app/comm/issue/ENG-9273/update-the-reply-count-for-thick-sidebars). Depends on D13426 Test Plan: 1. Reply count on sender. 2. Reply count on receiver. 3. Reply count when retrying. Tested both web and native. Reviewers: tomek, marcin Reviewed By: tomek Subscribers: ashoat Differential Revision: https://phab.comm.dev/D13427 --- lib/shared/dm-ops/process-dm-ops.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/shared/dm-ops/process-dm-ops.js b/lib/shared/dm-ops/process-dm-ops.js index 64cc55eb89..e30994354d 100644 --- a/lib/shared/dm-ops/process-dm-ops.js +++ b/lib/shared/dm-ops/process-dm-ops.js @@ -344,16 +344,34 @@ function useSendComposableDMOperation(): ( 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,