[core] Fix MessageTracker group counts after deleting messages

This commit is contained in:
Torsten Grote
2019-10-09 13:19:43 -03:00
parent a23e0699d8
commit 41676065c5
6 changed files with 69 additions and 12 deletions

View File

@@ -47,8 +47,8 @@ public interface MessageTracker {
throws DbException;
/**
* Loads the stored message id for the respective group id or returns null
* if none is available.
* Loads the stored message id for the respective group id or returns null
* if none is available.
*/
@Nullable
MessageId loadStoredMessageId(GroupId g) throws DbException;
@@ -64,6 +64,16 @@ public interface MessageTracker {
*/
void setReadFlag(GroupId g, MessageId m, boolean read) throws DbException;
/**
* Resets the {@link GroupCount} to the given msgCount and unreadCount.
* The latestMsgTime will be set to the current time.
* <p>
* Such reset is needed when recalculating the counts
* after deleting messages from a group.
*/
void resetGroupCount(Transaction txn, GroupId g, int msgCount,
int unreadCount) throws DbException;
class GroupCount {
private final int msgCount, unreadCount;