Update CallLogEvent to latest spec
This commit is contained in:
parent
815fd77849
commit
fc08e70c0f
12 changed files with 366 additions and 142 deletions
|
@ -3,39 +3,56 @@
|
|||
|
||||
import type { CallLogEventSyncEvent } from '../textsecure/messageReceiverEvents';
|
||||
import * as log from '../logging/log';
|
||||
import type { CallLogEventTarget } from '../types/CallDisposition';
|
||||
import { CallLogEvent } from '../types/CallDisposition';
|
||||
import { missingCaseError } from './missingCaseError';
|
||||
import { strictAssert } from './assert';
|
||||
import { updateDeletedMessages } from './callDisposition';
|
||||
|
||||
export async function onCallLogEventSync(
|
||||
syncEvent: CallLogEventSyncEvent
|
||||
): Promise<void> {
|
||||
const { callLogEvent, confirm } = syncEvent;
|
||||
const { event, timestamp } = callLogEvent;
|
||||
const { data, confirm } = syncEvent;
|
||||
const { type, peerId, callId, timestamp } = data.callLogEventDetails;
|
||||
|
||||
const target: CallLogEventTarget = {
|
||||
peerId,
|
||||
callId,
|
||||
timestamp,
|
||||
};
|
||||
|
||||
log.info(
|
||||
`onCallLogEventSync: Processing event (Event: ${event}, Timestamp: ${timestamp})`
|
||||
`onCallLogEventSync: Processing event (Event: ${type}, CallId: ${callId}, Timestamp: ${timestamp})`
|
||||
);
|
||||
|
||||
if (event === CallLogEvent.Clear) {
|
||||
log.info(`onCallLogEventSync: Clearing call history before ${timestamp}`);
|
||||
if (type === CallLogEvent.Clear) {
|
||||
log.info('onCallLogEventSync: Clearing call history');
|
||||
try {
|
||||
await window.Signal.Data.clearCallHistory(timestamp);
|
||||
const messageIds = await window.Signal.Data.clearCallHistory(target);
|
||||
updateDeletedMessages(messageIds);
|
||||
} finally {
|
||||
// We want to reset the call history even if the clear fails.
|
||||
window.reduxActions.callHistory.resetCallHistory();
|
||||
}
|
||||
confirm();
|
||||
} else if (event === CallLogEvent.MarkedAsRead) {
|
||||
log.info(
|
||||
`onCallLogEventSync: Marking call history read before ${timestamp}`
|
||||
);
|
||||
} else if (type === CallLogEvent.MarkedAsRead) {
|
||||
log.info('onCallLogEventSync: Marking call history read');
|
||||
try {
|
||||
await window.Signal.Data.markAllCallHistoryRead(timestamp);
|
||||
await window.Signal.Data.markAllCallHistoryRead(target);
|
||||
} finally {
|
||||
window.reduxActions.callHistory.updateCallHistoryUnreadCount();
|
||||
}
|
||||
confirm();
|
||||
} else if (type === CallLogEvent.MarkedAsReadInConversation) {
|
||||
log.info('onCallLogEventSync: Marking call history read in conversation');
|
||||
try {
|
||||
strictAssert(peerId, 'Missing peerId');
|
||||
await window.Signal.Data.markAllCallHistoryReadInConversation(target);
|
||||
} finally {
|
||||
window.reduxActions.callHistory.updateCallHistoryUnreadCount();
|
||||
}
|
||||
confirm();
|
||||
} else {
|
||||
throw missingCaseError(event);
|
||||
throw missingCaseError(type);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue