Fix crash on multi-archive.

This commit is contained in:
Alex Hart
2020-08-24 14:48:23 -03:00
committed by Greyson Parrelli
parent c5c2fb31b1
commit 12a8d4e10b
3 changed files with 38 additions and 15 deletions

View File

@@ -544,7 +544,7 @@ public class ThreadDatabase extends Database {
String query = RECIPIENT_ID + " = ?";
for (Map.Entry<RecipientId, Boolean> entry : status.entrySet()) {
ContentValues values = new ContentValues(1);
ContentValues values = new ContentValues(2);
if (entry.getValue()) {
values.put(PINNED, "0");
@@ -561,6 +561,29 @@ public class ThreadDatabase extends Database {
}
}
public void setArchived(Set<Long> threadIds, boolean archive) {
SQLiteDatabase db = databaseHelper.getReadableDatabase();
db.beginTransaction();
try {
for (long threadId : threadIds) {
ContentValues values = new ContentValues(2);
if (archive) {
values.put(PINNED, "0");
}
values.put(ARCHIVED, archive ? "1" : "0");
db.update(TABLE_NAME, values, ID_WHERE, SqlUtil.buildArgs(threadId));
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
notifyConversationListListeners();
}
}
public @NonNull Set<RecipientId> getArchivedRecipients() {
Set<RecipientId> archived = new HashSet<>();