mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-24 10:28:03 +01:00
Support for local deletes synced to all your devices
This commit is contained in:
@@ -115,7 +115,7 @@ const exclusiveInterface: ClientExclusiveInterface = {
|
||||
flushUpdateConversationBatcher,
|
||||
|
||||
shutdown,
|
||||
removeAllMessagesInConversation,
|
||||
removeMessagesInConversation,
|
||||
|
||||
removeOtherData,
|
||||
cleanupOrphanedAttachments,
|
||||
@@ -592,6 +592,21 @@ async function removeMessage(id: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteAndCleanup(
|
||||
messages: Array<MessageAttributesType>,
|
||||
logId: string
|
||||
): Promise<void> {
|
||||
const ids = messages.map(message => message.id);
|
||||
|
||||
log.info(`deleteAndCleanup/${logId}: Deleting ${ids.length} messages...`);
|
||||
await channels.removeMessages(ids);
|
||||
|
||||
log.info(`deleteAndCleanup/${logId}: Cleanup for ${ids.length} messages...`);
|
||||
await _cleanupMessages(messages);
|
||||
|
||||
log.info(`deleteAndCleanup/${logId}: Complete`);
|
||||
}
|
||||
|
||||
async function _cleanupMessages(
|
||||
messages: ReadonlyArray<MessageAttributesType>
|
||||
): Promise<void> {
|
||||
@@ -664,12 +679,14 @@ async function getConversationRangeCenteredOnMessage(
|
||||
};
|
||||
}
|
||||
|
||||
async function removeAllMessagesInConversation(
|
||||
async function removeMessagesInConversation(
|
||||
conversationId: string,
|
||||
{
|
||||
logId,
|
||||
receivedAt,
|
||||
}: {
|
||||
logId: string;
|
||||
receivedAt?: number;
|
||||
}
|
||||
): Promise<void> {
|
||||
let messages;
|
||||
@@ -685,6 +702,7 @@ async function removeAllMessagesInConversation(
|
||||
conversationId,
|
||||
limit: chunkSize,
|
||||
includeStoryReplies: true,
|
||||
receivedAt,
|
||||
storyId: undefined,
|
||||
});
|
||||
|
||||
@@ -692,15 +710,8 @@ async function removeAllMessagesInConversation(
|
||||
return;
|
||||
}
|
||||
|
||||
const ids = messages.map(message => message.id);
|
||||
|
||||
log.info(`removeAllMessagesInConversation/${logId}: Cleanup...`);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await _cleanupMessages(messages);
|
||||
|
||||
log.info(`removeAllMessagesInConversation/${logId}: Deleting...`);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await channels.removeMessages(ids);
|
||||
await deleteAndCleanup(messages, logId);
|
||||
} while (messages.length > 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user