fix a issue that the unread count can be negative

This commit is contained in:
ryanzhao 2021-08-12 16:37:53 +10:00
parent 9dcc5dd848
commit 4f89c33676
1 changed files with 1 additions and 1 deletions

View File

@ -297,7 +297,7 @@ public class ThreadDatabase extends Database {
public void decrementUnread(long threadId, int amount) {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_NAME + " SET " + READ + " = 0, " +
UNREAD_COUNT + " = " + UNREAD_COUNT + " - ? WHERE " + ID + " = ?",
UNREAD_COUNT + " = " + UNREAD_COUNT + " - ? WHERE " + ID + " = ? AND " + UNREAD_COUNT + " > 0",
new String[] {String.valueOf(amount),
String.valueOf(threadId)});
}