Skip to content

Commit

Permalink
Fix issue with thread summaries being updated after message deletion.
Browse files Browse the repository at this point in the history
Fixes #9902
  • Loading branch information
greyson-signal committed Aug 3, 2020
1 parent 566285e commit 1ec3a72
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ public void onRecipientChanged(@NonNull Recipient recipient) {
return emphasisAdded(context.getString(R.string.ThreadRecord_you_marked_unverified));
} else if (SmsDatabase.Types.isUnsupportedMessageType(thread.getType())) {
return emphasisAdded(context.getString(R.string.ThreadRecord_message_could_not_be_processed));
} else if (SmsDatabase.Types.isProfileChange(thread.getType())) {
return emphasisAdded("");
} else {
ThreadDatabase.Extra extra = thread.getExtra();
if (extra != null && extra.isViewOnce()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@ private boolean update(@NonNull SqlUtil.UpdateQuery updateQuery, @NonNull Conten
Log.w(TAG, "Had no sessions. No action necessary.");
}

DatabaseFactory.getThreadDatabase(context).update(threadMerge.threadId, false, false);
DatabaseFactory.getThreadDatabase(context).update(threadMerge.threadId, false, false, false);

return byUuid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ public boolean deleteMessage(long messageId) {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
long threadId = getThreadIdForMessage(messageId);
db.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""});
boolean threadDeleted = DatabaseFactory.getThreadDatabase(context).update(threadId, false);
boolean threadDeleted = DatabaseFactory.getThreadDatabase(context).update(threadId, false, true, true);
notifyConversationListeners(threadId);
return threadDeleted;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private long createThreadForRecipient(@NonNull RecipientId recipientId, boolean
private void updateThread(long threadId, long count, String body, @Nullable Uri attachment,
@Nullable String contentType, @Nullable Extra extra,
long date, int status, int deliveryReceiptCount, long type, boolean unarchive,
long expiresIn, int readReceiptCount)
long expiresIn, int readReceiptCount, boolean causedByDeletion)
{
String extraSerialized = null;

Expand All @@ -178,7 +178,7 @@ private void updateThread(long threadId, long count, String body, @Nullable Uri
}

ContentValues contentValues = new ContentValues();
if (!MmsSmsColumns.Types.isProfileChange(type)) {
if (!MmsSmsColumns.Types.isProfileChange(type) || causedByDeletion) {
contentValues.put(DATE, date - date % 1000);
contentValues.put(SNIPPET, body);
contentValues.put(SNIPPET_URI, attachment == null ? null : attachment.toString());
Expand Down Expand Up @@ -814,10 +814,10 @@ void updateReadState(long threadId) {
}

public boolean update(long threadId, boolean unarchive) {
return update(threadId, unarchive, true);
return update(threadId, unarchive, true, false);
}

public boolean update(long threadId, boolean unarchive, boolean allowDeletion) {
public boolean update(long threadId, boolean unarchive, boolean allowDeletion, boolean causedByDeletion) {
MmsSmsDatabase mmsSmsDatabase = DatabaseFactory.getMmsSmsDatabase(context);
long count = mmsSmsDatabase.getConversationCount(threadId);

Expand All @@ -839,7 +839,7 @@ public boolean update(long threadId, boolean unarchive, boolean allowDeletion) {
updateThread(threadId, count, ThreadBodyUtil.getFormattedBodyFor(context, record), getAttachmentUriFor(record),
getContentTypeFor(record), getExtrasFor(record),
record.getTimestamp(), record.getDeliveryStatus(), record.getDeliveryReceiptCount(),
record.getType(), unarchive, record.getExpiresIn(), record.getReadReceiptCount());
record.getType(), unarchive, record.getExpiresIn(), record.getReadReceiptCount(), causedByDeletion);
notifyConversationListListeners();
return false;
} else {
Expand Down

0 comments on commit 1ec3a72

Please sign in to comment.