diff --git a/Telegram/SourceFiles/data/components/sponsored_messages.cpp b/Telegram/SourceFiles/data/components/sponsored_messages.cpp index 57c9c0688..ccd7ead26 100644 --- a/Telegram/SourceFiles/data/components/sponsored_messages.cpp +++ b/Telegram/SourceFiles/data/components/sponsored_messages.cpp @@ -204,8 +204,10 @@ bool SponsoredMessages::canHaveFor(not_null history) const { } bool SponsoredMessages::isTopBarFor(not_null history) const { - if (const auto user = history->peer->asUser()) { - return user->isBot(); + if (peerIsUser(history->peer->id)) { + if (const auto user = history->peer->asUser()) { + return user->isBot(); + } } return false; } diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 10a41d76b..81e160e85 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4429,7 +4429,6 @@ void HistoryWidget::showAnimated( if (_pinnedBar) { _pinnedBar->finishAnimating(); } - checkSponsoredMessageBar(); if (_translateBar) { _translateBar->finishAnimating(); } @@ -4501,6 +4500,7 @@ void HistoryWidget::doneShow() { if (_pinnedBar) { _pinnedBar->finishAnimating(); } + checkSponsoredMessageBar(); if (_sponsoredMessageBar) { _sponsoredMessageBar->finishAnimating(); } @@ -7628,13 +7628,15 @@ void HistoryWidget::requestSponsoredMessageBar() { } void HistoryWidget::checkSponsoredMessageBar() { - if (!_history) { + if (!_history || !session().sponsoredMessages().isTopBarFor(_history)) { return; } const auto state = session().sponsoredMessages().state(_history); if (state == Data::SponsoredMessages::State::AppendToTopBar) { if (checkSponsoredMessageBarVisibility()) { - createSponsoredMessageBar(); + if (!_sponsoredMessageBar) { + createSponsoredMessageBar(); + } _sponsoredMessageBar->toggle(true, anim::type::instant); } }