Don't read history for guest channels.

This commit is contained in:
John Preston 2020-02-21 11:34:24 +04:00
parent a954b459b4
commit 9bdcd08233
4 changed files with 12 additions and 2 deletions

View File

@ -135,6 +135,8 @@ void Histories::readInboxTill(
if (!history->readInboxTillNeedsRequest(tillId) && !force) {
return;
} else if (!history->trackUnreadMessages()) {
return;
} else if (!force) {
const auto maybeState = lookup(history);
if (maybeState && maybeState->readTill >= tillId) {

View File

@ -1595,7 +1595,7 @@ void History::calculateFirstUnreadMessage() {
}
_firstUnreadView = nullptr;
if (!unreadCount()) {
if (!unreadCount() || !trackUnreadMessages()) {
return;
}
for (const auto &block : ranges::view::reverse(blocks)) {
@ -2575,6 +2575,13 @@ int History::fixedOnTopIndex() const {
return useProxyPromotion() ? kProxyPromotionFixOnTopIndex : 0;
}
bool History::trackUnreadMessages() const {
if (const auto channel = peer->asChannel()) {
return channel->amIn();
}
return true;
}
bool History::shouldBeInChatList() const {
if (peer->migrateTo() || !folderKnown()) {
return false;

View File

@ -191,6 +191,7 @@ public:
not_null<const HistoryItem*> item) const;
[[nodiscard]] MsgId loadAroundId() const;
[[nodiscard]] bool trackUnreadMessages() const;
[[nodiscard]] int unreadCount() const;
[[nodiscard]] bool unreadCountKnown() const;

View File

@ -5212,7 +5212,7 @@ void HistoryWidget::addMessagesToBack(
PeerData *peer,
const QVector<MTPMessage> &messages) {
const auto checkForUnreadStart = [&] {
if (_history->unreadBar() || !_history->inChatList()) {
if (_history->unreadBar() || !_history->trackUnreadMessages()) {
return false;
}
_history->calculateFirstUnreadMessage();