Enforce changelog message visibility.

This commit is contained in:
John Preston 2019-04-22 21:44:08 +04:00
parent ceec71d3e6
commit 40532e32ab
3 changed files with 21 additions and 15 deletions
Telegram/SourceFiles/history

View File

@ -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(

View File

@ -452,7 +452,6 @@ private:
void clearSendAction(not_null<UserData*> from);
bool clearUnreadOnClientSide() const;
bool skipUnreadUpdate() const;
bool skipUnreadUpdateForClientSideUnread() const;
HistoryItem *lastAvailableMessage() const;
void getNextFirstUnreadMessage();

View File

@ -127,6 +127,22 @@ void InsertEmojiToField(not_null<Ui::InputField*> field, EmojiPtr emoji) {
}
}
bool ShowHistoryEndInsteadOfUnread(
not_null<Data::Session*> 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();