Skip to content

Commit

Permalink
Add thread delete progress logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal committed Dec 9, 2024
1 parent c2aceb2 commit c91123e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,10 @@ protected void onPreExecute() {

@Override
protected Void doInBackground(Void... params) {
Log.d(TAG, "[handleDelete] Deleting " + selectedConversations.size() + " chats");
SignalDatabase.threads().deleteConversations(selectedConversations, true);
AppDependencies.getMessageNotifier().updateNotification(requireActivity());
Log.d(TAG, "[handleDelete] Delete complete");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1261,11 +1261,13 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
}

fun deleteConversations(selectedConversations: Set<Long>, syncThreadDeletes: Boolean = true) {
Log.d(TAG, "[deleteConversations] Deleting ${selectedConversations.size} chats syncThreadDeletes: $syncThreadDeletes")
val recipientIds = getRecipientIdsForThreadIds(selectedConversations)

val addressableMessages = mutableListOf<ThreadDeleteSyncInfo>()

val queries: List<SqlUtil.Query> = SqlUtil.buildCollectionQuery(ID, selectedConversations)
Log.d(TAG, "[deleteConversations] Enter transaction")
writableDatabase.withinTransaction { db ->
if (syncThreadDeletes) {
for (threadId in selectedConversations) {
Expand All @@ -1278,24 +1280,35 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa

addressableMessages += ThreadDeleteSyncInfo(threadId, mostRecentMessages, mostRecentNonExpiring)
}
Log.d(TAG, "[deleteConversations] Retrieved sync thread delete addressable messages (${addressableMessages.size})")
} else {
Log.d(TAG, "[deleteConversations] No addressable messages needed")
}

Log.d(TAG, "[deleteConversations] Deactivating threads")
for (query in queries) {
db.deactivateThread(query)
}

Log.d(TAG, "[deleteConversations] Deleting messages in thread")
messages.deleteMessagesInThread(selectedConversations)
Log.d(TAG, "[deleteConversations] Trimming attachments")
attachments.trimAllAbandonedAttachments()
Log.d(TAG, "[deleteConversations] Deleting abandoned group receipts")
groupReceipts.deleteAbandonedRows()
Log.d(TAG, "[deleteConversations] Deleting abandoned mentions")
mentions.deleteAbandonedMentions()
Log.d(TAG, "[deleteConversations] Clearing drafts")
drafts.clearDrafts(selectedConversations)
Log.d(TAG, "[deleteConversations] Updating threadId cache")
synchronized(threadIdCache) {
for (recipientId in recipientIds) {
threadIdCache.remove(recipientId)
}
}
}

Log.d(TAG, "[deleteConversations] Enqueue jobs and notify listeners")
DeleteAbandonedAttachmentsJob.enqueue()

if (syncThreadDeletes) {
Expand Down

0 comments on commit c91123e

Please sign in to comment.