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) { if (!history->readInboxTillNeedsRequest(tillId) && !force) {
return; return;
} else if (!history->trackUnreadMessages()) {
return;
} else if (!force) { } else if (!force) {
const auto maybeState = lookup(history); const auto maybeState = lookup(history);
if (maybeState && maybeState->readTill >= tillId) { if (maybeState && maybeState->readTill >= tillId) {

View File

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

View File

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

View File

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