Fix call history deletion from sync messages
This commit is contained in:
@@ -785,8 +785,18 @@ async function updateLocalCallHistory(
|
||||
'updateLocalCallHistory: Saving call history:',
|
||||
formatCallHistory(callHistory)
|
||||
);
|
||||
|
||||
const isDeleted =
|
||||
callHistory.status === DirectCallStatus.Deleted ||
|
||||
callHistory.status === GroupCallStatus.Deleted;
|
||||
|
||||
await window.Signal.Data.saveCallHistory(callHistory);
|
||||
window.reduxActions.callHistory.cacheCallHistory(callHistory);
|
||||
|
||||
if (isDeleted) {
|
||||
window.reduxActions.callHistory.removeCallHistory(callHistory.callId);
|
||||
} else {
|
||||
window.reduxActions.callHistory.addCallHistory(callHistory);
|
||||
}
|
||||
|
||||
const prevMessage =
|
||||
await window.Signal.Data.getCallHistoryMessageByCallId({
|
||||
@@ -806,6 +816,13 @@ async function updateLocalCallHistory(
|
||||
);
|
||||
}
|
||||
|
||||
if (isDeleted) {
|
||||
if (prevMessage != null) {
|
||||
await window.Signal.Data.removeMessage(prevMessage.id);
|
||||
}
|
||||
return callHistory;
|
||||
}
|
||||
|
||||
let unread = false;
|
||||
if (callHistory.mode === CallMode.Direct) {
|
||||
unread =
|
||||
|
@@ -18,7 +18,12 @@ export async function onCallLogEventSync(
|
||||
|
||||
if (event === CallLogEvent.Clear) {
|
||||
log.info(`onCallLogEventSync: Clearing call history before ${timestamp}`);
|
||||
await window.Signal.Data.clearCallHistory(timestamp);
|
||||
try {
|
||||
await window.Signal.Data.clearCallHistory(timestamp);
|
||||
} finally {
|
||||
// We want to reset the call history even if the clear fails.
|
||||
window.reduxActions.callHistory.resetCallHistory();
|
||||
}
|
||||
confirm();
|
||||
} else {
|
||||
throw missingCaseError(event);
|
||||
|
Reference in New Issue
Block a user