diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index c124bd951..c78151ff5 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -2554,20 +2554,8 @@ bool History::clearUnreadOnClientSide() const { return false; } -bool History::skipUnreadUpdateForClientSideUnread() const { - if (peer->id != PeerData::kServiceNotificationsId) { - return false; - } else if (!_unreadCount || !*_unreadCount) { - return false; - } else if (!_lastMessage || IsServerMsgId((*_lastMessage)->id)) { - return false; - } - return true; -} - bool History::skipUnreadUpdate() const { - return skipUnreadUpdateForClientSideUnread() - || clearUnreadOnClientSide(); + return clearUnreadOnClientSide(); } void History::applyDialogFields( diff --git a/Telegram/SourceFiles/history/history.h b/Telegram/SourceFiles/history/history.h index fdef7d5b8..440414b60 100644 --- a/Telegram/SourceFiles/history/history.h +++ b/Telegram/SourceFiles/history/history.h @@ -452,7 +452,6 @@ private: void clearSendAction(not_null from); bool clearUnreadOnClientSide() const; bool skipUnreadUpdate() const; - bool skipUnreadUpdateForClientSideUnread() const; HistoryItem *lastAvailableMessage() const; void getNextFirstUnreadMessage(); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 1b4f04016..505b3b81d 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -127,6 +127,22 @@ void InsertEmojiToField(not_null field, EmojiPtr emoji) { } } +bool ShowHistoryEndInsteadOfUnread( + not_null session, + PeerId peerId) { + // Ignore unread messages in case of unread changelogs. + // We must show this history at end for the changelog to be visible. + if (peerId != PeerData::kServiceNotificationsId) { + return false; + } + const auto history = session->history(peerId); + if (!history->unreadCount()) { + return false; + } + const auto last = history->lastMessage(); + return (last != nullptr) && !IsServerMsgId(last->id); +} + } // namespace ReportSpamPanel::ReportSpamPanel(QWidget *parent) : TWidget(parent), @@ -1504,9 +1520,12 @@ void HistoryWidget::showHistory( MsgId wasMsgId = _showAtMsgId; History *wasHistory = _history; - bool startBot = (showAtMsgId == ShowAndStartBotMsgId); + const auto startBot = (showAtMsgId == ShowAndStartBotMsgId); if (startBot) { showAtMsgId = ShowAtTheEndMsgId; + } else if ((showAtMsgId == ShowAtUnreadMsgId) + && ShowHistoryEndInsteadOfUnread(&session().data(), peerId)) { + showAtMsgId = ShowAtTheEndMsgId; } clearHighlightMessages();