mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 23:12:10 +00:00
Attempted to fix incorrect display of about view for bots with forum.
This commit is contained in:
@@ -4718,6 +4718,9 @@ void HistoryInner::refreshAboutView(bool force) {
|
||||
_aboutView->refreshRequests() | rpl::on_next([=] {
|
||||
updateBotInfo();
|
||||
}, _aboutView->lifetime());
|
||||
_aboutView->destroyRequests() | rpl::on_next([=] {
|
||||
refreshAboutView(true);
|
||||
}, _aboutView->lifetime());
|
||||
_aboutView->sendIntroSticker() | rpl::start_to_stream(
|
||||
_sendIntroSticker,
|
||||
_aboutView->lifetime());
|
||||
|
||||
@@ -610,6 +610,14 @@ AboutView::AboutView(
|
||||
not_null<ElementDelegate*> delegate)
|
||||
: _history(history)
|
||||
, _delegate(delegate) {
|
||||
if (_history->peer->isBot() && _history->peer->isForum()) {
|
||||
_history->session().data().newItemAdded(
|
||||
) | rpl::on_next([=](not_null<HistoryItem*> item) {
|
||||
if (item->history() == _history) {
|
||||
_destroyRequests.fire({});
|
||||
}
|
||||
}, lifetime());
|
||||
}
|
||||
}
|
||||
|
||||
AboutView::~AboutView() {
|
||||
@@ -632,7 +640,13 @@ HistoryItem *AboutView::item() const {
|
||||
}
|
||||
|
||||
bool AboutView::aboveHistory() const {
|
||||
return !_history->peer->isBot() || !_history->isForum();
|
||||
if (!_history->peer->isBot() || !_history->isForum()) {
|
||||
return true;
|
||||
}
|
||||
const auto info = _history->peer->asUser()->botInfo.get();
|
||||
return !(info->canManageTopics
|
||||
&& info->startToken.isEmpty()
|
||||
&& (!_history->isEmpty() || _history->lastMessage()));
|
||||
}
|
||||
|
||||
bool AboutView::refresh() {
|
||||
@@ -781,6 +795,10 @@ rpl::producer<> AboutView::refreshRequests() const {
|
||||
return _refreshRequests.events();
|
||||
}
|
||||
|
||||
rpl::producer<> AboutView::destroyRequests() const {
|
||||
return _destroyRequests.events();
|
||||
}
|
||||
|
||||
rpl::lifetime &AboutView::lifetime() {
|
||||
return _lifetime;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
[[nodiscard]] auto sendIntroSticker() const
|
||||
-> rpl::producer<not_null<DocumentData*>>;
|
||||
[[nodiscard]] rpl::producer<> refreshRequests() const;
|
||||
[[nodiscard]] rpl::producer<> destroyRequests() const;
|
||||
[[nodiscard]] rpl::lifetime &lifetime();
|
||||
|
||||
int top = 0;
|
||||
@@ -73,6 +74,7 @@ private:
|
||||
bool _commonGroupsRequested = false;
|
||||
std::vector<not_null<PeerData*>> _commonGroups;
|
||||
rpl::event_stream<> _refreshRequests;
|
||||
rpl::event_stream<> _destroyRequests;
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user