Skip to content

Commit 8cb80f6

Browse files
Fix repeated call messages for timestamp updates
1 parent 6bf7151 commit 8cb80f6

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

ts/util/callDisposition.ts

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,38 +1497,46 @@ export async function updateLocalGroupCallHistoryTimestamp(
14971497
if (conversation == null) {
14981498
return null;
14991499
}
1500-
const peerId = getPeerIdFromConversation(conversation.attributes);
15011500

1502-
const prevCallHistory =
1503-
(await DataReader.getCallHistory(callId, peerId)) ?? null;
1501+
return conversation.queueJob<CallHistoryDetails | null>(
1502+
'updateLocalGroupCallHistoryTimestamp',
1503+
async () => {
1504+
const peerId = getPeerIdFromConversation(conversation.attributes);
15041505

1505-
// We don't have all the details to add new call history here
1506-
if (prevCallHistory != null) {
1507-
log.info(
1508-
'updateLocalGroupCallHistoryTimestamp: Found previous call history:',
1509-
formatCallHistory(prevCallHistory)
1510-
);
1511-
} else {
1512-
log.info('updateLocalGroupCallHistoryTimestamp: No previous call history');
1513-
return null;
1514-
}
1506+
const prevCallHistory =
1507+
(await DataReader.getCallHistory(callId, peerId)) ?? null;
15151508

1516-
if (timestamp >= prevCallHistory.timestamp) {
1517-
log.info(
1518-
'updateLocalGroupCallHistoryTimestamp: New timestamp is later than existing call history, ignoring'
1519-
);
1520-
return prevCallHistory;
1521-
}
1509+
// We don't have all the details to add new call history here
1510+
if (prevCallHistory != null) {
1511+
log.info(
1512+
'updateLocalGroupCallHistoryTimestamp: Found previous call history:',
1513+
formatCallHistory(prevCallHistory)
1514+
);
1515+
} else {
1516+
log.info(
1517+
'updateLocalGroupCallHistoryTimestamp: No previous call history'
1518+
);
1519+
return null;
1520+
}
15221521

1523-
const updatedCallHistory = await saveCallHistory({
1524-
callHistory: {
1525-
...prevCallHistory,
1526-
timestamp,
1527-
},
1528-
conversation,
1529-
receivedAtCounter: null,
1530-
receivedAtMS: null,
1531-
});
1522+
if (timestamp >= prevCallHistory.timestamp) {
1523+
log.info(
1524+
'updateLocalGroupCallHistoryTimestamp: New timestamp is later than existing call history, ignoring'
1525+
);
1526+
return prevCallHistory;
1527+
}
1528+
1529+
const updatedCallHistory = await saveCallHistory({
1530+
callHistory: {
1531+
...prevCallHistory,
1532+
timestamp,
1533+
},
1534+
conversation,
1535+
receivedAtCounter: null,
1536+
receivedAtMS: null,
1537+
});
15321538

1533-
return updatedCallHistory;
1539+
return updatedCallHistory;
1540+
}
1541+
);
15341542
}

0 commit comments

Comments
 (0)