Handle new sync message MarkedAsRead for Calls Tab

This commit is contained in:
ayumi-signal 2024-03-11 11:18:55 -07:00 committed by GitHub
parent b410d14753
commit c332bd240f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 72 additions and 16 deletions

View file

@ -1056,6 +1056,49 @@ export async function clearCallHistoryDataAndSync(): Promise<void> {
}
}
export async function markAllCallHistoryReadAndSync(): Promise<void> {
try {
const timestamp = Date.now();
log.info(
`markAllCallHistoryReadAndSync: Marking call history read before ${timestamp}`
);
await window.Signal.Data.markAllCallHistoryRead(timestamp);
const ourAci = window.textsecure.storage.user.getCheckedAci();
const callLogEvent = new Proto.SyncMessage.CallLogEvent({
type: Proto.SyncMessage.CallLogEvent.Type.MARKED_AS_READ,
timestamp: Long.fromNumber(timestamp),
});
const syncMessage = MessageSender.createSyncMessage();
syncMessage.callLogEvent = callLogEvent;
const contentMessage = new Proto.Content();
contentMessage.syncMessage = syncMessage;
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
log.info('markAllCallHistoryReadAndSync: Queueing sync message');
await singleProtoJobQueue.add({
contentHint: ContentHint.RESENDABLE,
serviceId: ourAci,
isSyncMessage: true,
protoBase64: Bytes.toBase64(
Proto.Content.encode(contentMessage).finish()
),
type: 'callLogEventSync',
urgent: false,
});
} catch (error) {
log.error(
'markAllCallHistoryReadAndSync: Failed to mark call history read',
error
);
}
}
export async function updateLocalGroupCallHistoryTimestamp(
conversationId: string,
callId: string,