Ignore unread counts from deleted (support).

This commit is contained in:
John Preston 2018-10-08 16:41:14 +03:00
parent 9d4d3cc5e3
commit 83919492d3
2 changed files with 29 additions and 1 deletions

View File

@ -1714,6 +1714,9 @@ void History::setUnreadCount(int newUnreadCount) {
}
void History::setUnreadMark(bool unread) {
if (clearUnreadOnClientSide()) {
unread = false;
}
if (_unreadMark != unread) {
_unreadMark = unread;
if (!_unreadCount || !*_unreadCount) {
@ -2285,6 +2288,18 @@ void History::applyDialog(const MTPDdialog &data) {
}
}
bool History::clearUnreadOnClientSide() const {
if (!Auth().supportMode()) {
return false;
}
if (const auto user = peer->asUser()) {
if (user->flags() & MTPDuser::Flag::f_deleted) {
return true;
}
}
return false;
}
bool History::skipUnreadUpdateForClientSideUnread() const {
if (peer->id != peerFromUser(ServiceUserId)) {
return false;
@ -2296,11 +2311,16 @@ bool History::skipUnreadUpdateForClientSideUnread() const {
return true;
}
bool History::skipUnreadUpdate() const {
return skipUnreadUpdateForClientSideUnread()
|| clearUnreadOnClientSide();
}
void History::applyDialogFields(
int unreadCount,
MsgId maxInboxRead,
MsgId maxOutboxRead) {
if (!skipUnreadUpdateForClientSideUnread()) {
if (!skipUnreadUpdate()) {
setUnreadCount(unreadCount);
setInboxReadTill(maxInboxRead);
}
@ -2320,6 +2340,12 @@ void History::applyDialogTopMessage(MsgId topMessageId) {
} else {
setLastMessage(nullptr);
}
if (clearUnreadOnClientSide()) {
setUnreadCount(0);
if (const auto last = lastMessage()) {
setInboxReadTill(last->id);
}
}
}
void History::setInboxReadTill(MsgId upTo) {

View File

@ -471,6 +471,8 @@ private:
void addItemsToLists(const std::vector<not_null<HistoryItem*>> &items);
void clearSendAction(not_null<UserData*> from);
bool clearUnreadOnClientSide() const;
bool skipUnreadUpdate() const;
bool skipUnreadUpdateForClientSideUnread() const;
HistoryItem *lastAvailableMessage() const;