Display total unread messages including mark as unread instead of unread thread count.

This commit is contained in:
Alex Hart
2022-03-24 14:39:16 -03:00
committed by Greyson Parrelli
parent 8d4419705b
commit 65bfee6eba
2 changed files with 25 additions and 2 deletions

View File

@@ -724,6 +724,29 @@ public class ThreadDatabase extends Database {
return positions;
}
public long getTabBarUnreadCount() {
String[] countProjection = SqlUtil.buildArgs("COUNT(*)");
String[] sumProjection = SqlUtil.buildArgs("SUM(" + UNREAD_COUNT + ")");
String where = ARCHIVED + " = 0 AND " + MEANINGFUL_MESSAGES + " != 0 AND " + READ + " = ?";
String[] countArgs = SqlUtil.buildArgs(ReadStatus.FORCED_UNREAD.serialize());
String[] sumArgs = SqlUtil.buildArgs(ReadStatus.UNREAD.serialize());
long total = 0;
try (Cursor cursor = getReadableDatabase().query(TABLE_NAME, countProjection, where, countArgs, null, null, null)) {
if (cursor != null && cursor.moveToFirst()) {
total += cursor.getLong(0);
}
}
try (Cursor cursor = getReadableDatabase().query(TABLE_NAME, sumProjection, where, sumArgs, null, null, null)) {
if (cursor != null && cursor.moveToFirst()) {
total += cursor.getLong(0);
}
}
return total;
}
public Cursor getArchivedConversationList(long offset, long limit) {
return getConversationList("1", offset, limit);
}