diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index db703ee05..5544f1912 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -4275,32 +4275,32 @@ auto HistoryInner::findViewForPinnedTracking(int top) const return { nullptr, 0 }; } -void HistoryInner::refreshAboutView() { +void HistoryInner::refreshAboutView(bool force) { + const auto refresh = [&] { + if (force) { + _aboutView = nullptr; + } + if (!_aboutView) { + _aboutView = std::make_unique( + _history, + _history->delegateMixin()->delegate()); + } + }; if (const auto user = _peer->asUser()) { if (const auto info = user->botInfo.get()) { - if (!_aboutView) { - _aboutView = std::make_unique( - _history, - _history->delegateMixin()->delegate()); - } + refresh(); if (!info->inited) { session().api().requestFullPeer(user); } } else if (user->meRequiresPremiumToWrite() && !user->session().premium() && !historyHeight()) { - if (!_aboutView) { - _aboutView = std::make_unique( - _history, - _history->delegateMixin()->delegate()); - } + refresh(); } else if (!historyHeight()) { if (!user->isFullLoaded()) { session().api().requestFullPeer(user); - } else if (!_aboutView) { - _aboutView = std::make_unique( - _history, - _history->delegateMixin()->delegate()); + } else { + refresh(); } } } diff --git a/Telegram/SourceFiles/history/history_inner_widget.h b/Telegram/SourceFiles/history/history_inner_widget.h index 030a53adc..c954c378f 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.h +++ b/Telegram/SourceFiles/history/history_inner_widget.h @@ -201,7 +201,7 @@ public: [[nodiscard]] std::pair findViewForPinnedTracking( int top) const; - void refreshAboutView(); + void refreshAboutView(bool force = false); void notifyMigrateUpdated(); // Ui::AbstractTooltipShower interface. diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 573f130fc..5746ab0c2 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -8017,13 +8017,18 @@ void HistoryWidget::handlePeerUpdate() { } } if (!_showAnimation) { - if (_unblock->isHidden() == isBlocked() + const auto blockChanged = (_unblock->isHidden() == isBlocked()); + if (blockChanged || (!isBlocked() && _joinChannel->isHidden() == isJoinChannel())) { resize = true; } if (updateCanSendMessage()) { resize = true; } + if (blockChanged) { + _list->refreshAboutView(true); + _list->updateBotInfo(); + } updateControlsVisibility(); if (resize) { updateControlsGeometry(); diff --git a/Telegram/SourceFiles/history/view/history_view_about_view.cpp b/Telegram/SourceFiles/history/view/history_view_about_view.cpp index 924035744..3e6a46bc8 100644 --- a/Telegram/SourceFiles/history/view/history_view_about_view.cpp +++ b/Telegram/SourceFiles/history/view/history_view_about_view.cpp @@ -245,6 +245,8 @@ bool AboutView::refresh() { } else if (user->meRequiresPremiumToWrite() && !user->session().premium()) { setItem(makePremiumRequired(), nullptr); + } else if (user->isBlocked()) { + setItem(makeBlocked(), nullptr); } else { makeIntro(user); } @@ -393,4 +395,17 @@ AdminLog::OwnedItem AboutView::makePremiumRequired() { return result; } +AdminLog::OwnedItem AboutView::makeBlocked() { + const auto item = _history->makeMessage({ + .id = _history->nextNonHistoryEntryId(), + .flags = (MessageFlag::FakeAboutView + | MessageFlag::FakeHistoryItem + | MessageFlag::Local), + .from = _history->peer->id, + }, PreparedServiceText{ + { tr::lng_chat_intro_default_title(tr::now) } + }); + return AdminLog::OwnedItem(_delegate, item); +} + } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/history_view_about_view.h b/Telegram/SourceFiles/history/view/history_view_about_view.h index c922157c9..0f4d90491 100644 --- a/Telegram/SourceFiles/history/view/history_view_about_view.h +++ b/Telegram/SourceFiles/history/view/history_view_about_view.h @@ -36,6 +36,7 @@ public: private: [[nodiscard]] AdminLog::OwnedItem makeAboutBot(not_null info); [[nodiscard]] AdminLog::OwnedItem makePremiumRequired(); + [[nodiscard]] AdminLog::OwnedItem makeBlocked(); void makeIntro(not_null user); void setItem(AdminLog::OwnedItem item, DocumentData *sticker); void setHelloChosen(not_null sticker);