From b1e2a4243e6d90b1a68e3cfb6cd92b571f2a7c2c Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 29 Nov 2024 20:17:10 +0400 Subject: [PATCH] Fix join requests list for legacy groups. --- Telegram/SourceFiles/info/info_memento.cpp | 2 +- .../info_requests_list_widget.cpp | 40 ++++++++----------- .../requests_list/info_requests_list_widget.h | 10 ++--- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/Telegram/SourceFiles/info/info_memento.cpp b/Telegram/SourceFiles/info/info_memento.cpp index 7e38fb5d152f2..ce2b89d5d97f0 100644 --- a/Telegram/SourceFiles/info/info_memento.cpp +++ b/Telegram/SourceFiles/info/info_memento.cpp @@ -171,7 +171,7 @@ std::shared_ptr Memento::DefaultContent( return std::make_shared( peer->asChannel()); case Section::Type::RequestsList: - return std::make_shared(peer->asChannel()); + return std::make_shared(peer); case Section::Type::PeerGifts: return std::make_shared(peer->asUser()); case Section::Type::SavedSublists: diff --git a/Telegram/SourceFiles/info/requests_list/info_requests_list_widget.cpp b/Telegram/SourceFiles/info/requests_list/info_requests_list_widget.cpp index 70f638e1c74a4..2fae27d580423 100644 --- a/Telegram/SourceFiles/info/requests_list/info_requests_list_widget.cpp +++ b/Telegram/SourceFiles/info/requests_list/info_requests_list_widget.cpp @@ -8,7 +8,6 @@ For license and copyright information please follow this link: #include "info/requests_list/info_requests_list_widget.h" #include "boxes/peers/edit_peer_requests_box.h" -#include "data/data_channel.h" #include "info/info_controller.h" #include "ui/widgets/scroll_area.h" #include "ui/search_field_controller.h" @@ -28,10 +27,10 @@ class InnerWidget final InnerWidget( QWidget *parent, not_null controller, - not_null channel); + not_null peer); - [[nodiscard]] not_null channel() const { - return _channel; + [[nodiscard]] not_null peer() const { + return _peer; } rpl::producer scrollToRequests() const; @@ -67,7 +66,7 @@ class InnerWidget final const std::shared_ptr _show; not_null _controller; - const not_null _channel; + const not_null _peer; std::unique_ptr _listController; object_ptr _list; @@ -77,14 +76,14 @@ class InnerWidget final InnerWidget::InnerWidget( QWidget *parent, not_null controller, - not_null channel) + not_null peer) : RpWidget(parent) , _show(controller->uiShow()) , _controller(controller) -, _channel(channel) +, _peer(peer) , _listController(std::make_unique( controller, - _channel)) + _peer)) , _list(setupList(this, _listController.get())) { setContent(_list.data()); _listController->setDelegate(static_cast(this)); @@ -188,23 +187,19 @@ std::shared_ptr InnerWidget::peerListUiShow() { return _show; } -Memento::Memento(not_null channel) -: ContentMemento(channel, nullptr, PeerId()) { +Memento::Memento(not_null peer) +: ContentMemento(peer, nullptr, PeerId()) { } Section Memento::section() const { return Section(Section::Type::RequestsList); } -not_null Memento::channel() const { - return peer()->asChannel(); -} - object_ptr Memento::createWidget( QWidget *parent, not_null controller, const QRect &geometry) { - auto result = object_ptr(parent, controller, channel()); + auto result = object_ptr(parent, controller, peer()); result->setInternalState(geometry, this); return result; } @@ -222,21 +217,18 @@ Memento::~Memento() = default; Widget::Widget( QWidget *parent, not_null controller, - not_null channel) + not_null peer) : ContentWidget(parent, controller) { controller->setSearchEnabledByContent(true); - _inner = setInnerWidget(object_ptr( - this, - controller, - channel)); + _inner = setInnerWidget(object_ptr(this, controller, peer)); } rpl::producer Widget::title() { return tr::lng_manage_peer_requests(); } -not_null Widget::channel() const { - return _inner->channel(); +not_null Widget::peer() const { + return _inner->peer(); } bool Widget::showInternal(not_null memento) { @@ -244,7 +236,7 @@ bool Widget::showInternal(not_null memento) { return false; } if (auto requestsMemento = dynamic_cast(memento.get())) { - if (requestsMemento->channel() == channel()) { + if (requestsMemento->peer() == peer()) { restoreState(requestsMemento); return true; } @@ -261,7 +253,7 @@ void Widget::setInternalState( } std::shared_ptr Widget::doCreateMemento() { - auto result = std::make_shared(channel()); + auto result = std::make_shared(peer()); saveState(result.get()); return result; } diff --git a/Telegram/SourceFiles/info/requests_list/info_requests_list_widget.h b/Telegram/SourceFiles/info/requests_list/info_requests_list_widget.h index 32e04ac5d041f..a6bbb37d613dc 100644 --- a/Telegram/SourceFiles/info/requests_list/info_requests_list_widget.h +++ b/Telegram/SourceFiles/info/requests_list/info_requests_list_widget.h @@ -9,7 +9,7 @@ For license and copyright information please follow this link: #include "info/info_content_widget.h" -class ChannelData; +class PeerData; struct PeerListState; namespace Info::RequestsList { @@ -18,7 +18,7 @@ class InnerWidget; class Memento final : public ContentMemento { public: - explicit Memento(not_null channel); + explicit Memento(not_null peer); object_ptr createWidget( QWidget *parent, @@ -27,8 +27,6 @@ class Memento final : public ContentMemento { Section section() const override; - [[nodiscard]] not_null channel() const; - void setListState(std::unique_ptr state); std::unique_ptr listState(); @@ -44,9 +42,9 @@ class Widget final : public ContentWidget { Widget( QWidget *parent, not_null controller, - not_null channel); + not_null peer); - [[nodiscard]] not_null channel() const; + [[nodiscard]] not_null peer() const; bool showInternal( not_null memento) override;