Fix reading of client side unread messages.

This commit is contained in:
John Preston 2019-04-30 13:48:48 +04:00
parent c9552390e7
commit 39008bf6fe
4 changed files with 25 additions and 7 deletions

View file

@ -1540,9 +1540,21 @@ void History::calculateFirstUnreadMessage() {
}
}
void History::readClientSideMessages() {
for (const auto &block : blocks) {
for (const auto &view : block->messages) {
const auto item = view->data();
if (!item->out()) {
item->markClientSideAsRead();
}
}
}
}
MsgId History::readInbox() {
const auto upTo = msgIdForRead();
setUnreadCount(0);
readClientSideMessages();
if (upTo) {
inboxRead(upTo);
}

View file

@ -426,6 +426,7 @@ private:
void setInboxReadTill(MsgId upTo);
void setOutboxReadTill(MsgId upTo);
void readClientSideMessages();
void applyMessageChanges(
not_null<HistoryItem*> item,

View file

@ -659,6 +659,10 @@ bool HistoryItem::unread() const {
return (_flags & MTPDmessage_ClientFlag::f_clientside_unread);
}
void HistoryItem::markClientSideAsRead() {
_flags &= ~MTPDmessage_ClientFlag::f_clientside_unread;
}
MessageGroupId HistoryItem::groupId() const {
return _groupId;
}

View file

@ -111,16 +111,17 @@ public:
void removeMainView();
void destroy();
bool out() const {
[[nodiscard]] bool out() const {
return _flags & MTPDmessage::Flag::f_out;
}
bool unread() const;
bool mentionsMe() const {
[[nodiscard]] bool unread() const;
void markClientSideAsRead();
[[nodiscard]] bool mentionsMe() const {
return _flags & MTPDmessage::Flag::f_mentioned;
}
bool isUnreadMention() const;
bool isUnreadMedia() const;
bool hasUnreadMediaFlag() const;
[[nodiscard]] bool isUnreadMention() const;
[[nodiscard]] bool isUnreadMedia() const;
[[nodiscard]] bool hasUnreadMediaFlag() const;
void markMediaRead();
@ -129,7 +130,7 @@ public:
void savePreviousMedia() {
_savedMedia = _media->clone(this);
}
bool isEditingMedia() const {
[[nodiscard]] bool isEditingMedia() const {
return _savedMedia != nullptr;
}
void clearSavedMedia() {