Remove showing monoforums inside dialogs widget.

This commit is contained in:
John Preston 2025-05-30 17:40:09 +04:00
parent 0d43f16db2
commit 50b761fab2
11 changed files with 24 additions and 283 deletions

View file

@ -781,55 +781,11 @@ void InnerWidget::changeOpenedForum(Data::Forum *forum) {
}
}
void InnerWidget::changeOpenedMonoforum(Data::SavedMessages *monoforum) {
if (_savedSublists == monoforum) {
return;
}
stopReorderPinned();
clearSelection();
if (monoforum) {
saveChatsFilterScrollState(_filterId);
}
_filterId = monoforum
? 0
: _controller->activeChatsFilterCurrent();
if (_openedForum) {
// If we close it inside forum destruction we should not schedule.
session().data().forumIcons().scheduleUserpicsReset(_openedForum);
}
_savedSublists = monoforum;
_st = &st::defaultDialogRow;
refreshShownList();
_openedForumLifetime.destroy();
if (monoforum) {
rpl::merge(
monoforum->chatsListChanges(),
monoforum->chatsListLoadedEvents()
) | rpl::start_with_next([=] {
refresh();
}, _openedForumLifetime);
}
refreshWithCollapsedRows(true);
if (_loadMoreCallback) {
_loadMoreCallback();
}
if (!monoforum) {
restoreChatsFilterScrollState(_filterId);
}
}
void InnerWidget::showSavedSublists(ChannelData *parentChat) {
Expects(!parentChat || parentChat->monoforum());
void InnerWidget::showSavedSublists() {
Expects(!_geometryInited);
Expects(!_savedSublists);
_savedSublists = parentChat
? parentChat->monoforum()
: &session().data().savedMessages();
_savedSublists = &session().data().savedMessages();
stopReorderPinned();
clearSelection();

View file

@ -141,8 +141,7 @@ public:
void changeOpenedFolder(Data::Folder *folder);
void changeOpenedForum(Data::Forum *forum);
void changeOpenedMonoforum(Data::SavedMessages *monoforum);
void showSavedSublists(ChannelData *parentChat);
void showSavedSublists();
void selectSkip(int32 direction);
void selectSkipPage(int32 pixels, int32 direction);

View file

@ -79,7 +79,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_changes.h"
#include "data/data_download_manager.h"
#include "data/data_chat_filters.h"
#include "data/data_saved_messages.h"
#include "data/data_saved_sublist.h"
#include "data/data_stories.h"
#include "info/downloads/info_downloads_widget.h"
@ -420,8 +419,6 @@ Widget::Widget(
) | rpl::filter([=](const Data::HistoryUpdate &update) {
if (_openedForum) {
return (update.history == _openedForum->history());
} else if (_openedMonoforum) {
return (update.history->peer == _openedMonoforum->parentChat());
} else if (_openedFolder) {
return (update.history->folder() == _openedFolder)
&& !update.history->isPinnedDialog(FilterId());
@ -600,7 +597,6 @@ Widget::Widget(
_search->setFocusFast();
if (_childList) {
controller->closeForum();
controller->closeMonoforum();
}
});
@ -623,8 +619,6 @@ Widget::Widget(
searchMore();
} else if (_openedForum && state == WidgetState::Default) {
_openedForum->requestTopics();
} else if (_openedMonoforum && state == WidgetState::Default) {
_openedMonoforum->loadMore();
} else {
const auto folder = _inner->shownFolder();
if (!folder || !folder->chatsList()->loaded()) {
@ -673,16 +667,7 @@ Widget::Widget(
) | rpl::filter(!rpl::mappers::_1) | rpl::start_with_next([=] {
if (_openedForum) {
changeOpenedForum(nullptr, anim::type::normal);
} else if (_childList && !_childList->openedMonoforum()) {
closeChildList(anim::type::normal);
}
}, lifetime());
controller->shownMonoforum().changes(
) | rpl::filter(!rpl::mappers::_1) | rpl::start_with_next([=] {
if (_openedMonoforum) {
changeOpenedMonoforum(nullptr, anim::type::normal);
} else if (_childList && !_childList->openedForum()) {
} else if (_childList) {
closeChildList(anim::type::normal);
}
}, lifetime());
@ -811,7 +796,7 @@ void Widget::setupSwipeBack() {
}
});
}
if (controller()->shownForum().current()) { // #TODO monoforum
if (controller()->shownForum().current()) {
if (!isRightToLeft) {
return Ui::Controls::SwipeHandlerFinishData();
}
@ -932,7 +917,8 @@ void Widget::chosenRow(const ChosenRow &row) {
controller()->showForum(
forum,
Window::SectionShow().withChildColumn());
if (forum->channel()->viewForumAsMessages()) {
if (controller()->shownForum().current() == forum
&& forum->channel()->viewForumAsMessages()) {
controller()->showThread(
history,
ShowAtUnreadMsgId,
@ -940,27 +926,6 @@ void Widget::chosenRow(const ChosenRow &row) {
}
}
return;
//} else if (history
// && history->peer->amMonoforumAdmin()
// && !row.message.fullId) {
// const auto monoforum = history->peer->monoforum();
// if (controller()->shownMonoforum().current() == monoforum) {
// controller()->closeMonoforum();
// //} else if (row.newWindow) { // #TODO monoforum
// // controller()->showInNewWindow(
// // Window::SeparateId(Window::SeparateType::Forum, history));
// } else {
// controller()->showMonoforum(
// monoforum,
// Window::SectionShow().withChildColumn());
// if (!controller()->adaptive().isOneColumn()) {
// controller()->showThread(
// history,
// ShowAtUnreadMsgId,
// Window::SectionShow::Way::ClearStack);
// }
// }
// return;
} else if (history) {
const auto peer = history->peer;
const auto showAtMsgId = controller()->uniqueChatsInSearchResults()
@ -995,21 +960,6 @@ void Widget::chosenRow(const ChosenRow &row) {
}
controller()->openFolder(folder);
hideChildList();
} else if (const auto sublist = row.key.sublist()) {
using namespace Window;
auto params = SectionShow(SectionShow::Way::Forward);
params.dropSameFromStack = true;
params.highlightPart.text = _searchState.query;
if (!params.highlightPart.empty()) {
params.highlightPartOffsetHint = kSearchQueryOffsetHint;
}
if (false && row.newWindow) { // #TODO monoforum
controller()->showInNewWindow(
Window::SeparateId(sublist),
row.message.fullId.msg);
} else {
controller()->showThread(sublist, row.message.fullId.msg, params);
}
}
if (row.filteredRow && !session().supportMode()) {
if (_subsectionTopBar) {
@ -1084,8 +1034,7 @@ void Widget::setupTopBarSuggestions(not_null<Ui::VerticalLayout*> dialogs) {
) | rpl::filter(_1 == nullptr) | rpl::map([=] {
auto on = rpl::combine(
controller()->activeChatsFilter(),
_openedFolderOrForumOrMonoforumChanges.events_starting_with(
false),
_openedFolderOrForumChanges.events_starting_with(false),
widthValue() | rpl::map(
_1 >= st::columnMinimalWidthLeft
) | rpl::distinct_until_changed(),
@ -1094,11 +1043,11 @@ void Widget::setupTopBarSuggestions(not_null<Ui::VerticalLayout*> dialogs) {
_jumpToDate->toggledValue()
) | rpl::map([=](
FilterId id,
bool folderOrForumOrMonoforum,
bool folderOrForum,
bool wide,
bool search,
bool searchInPeer) {
return !folderOrForumOrMonoforum
return !folderOrForum
&& wide
&& !search
&& !searchInPeer
@ -1155,8 +1104,7 @@ void Widget::updateFrozenAccountBar() {
void Widget::updateTopBarSuggestions() {
if (_topBarSuggestion) {
_openedFolderOrForumOrMonoforumChanges.fire(
_openedFolder || _openedForum || _openedMonoforum);
_openedFolderOrForumChanges.fire(_openedFolder || _openedForum);
}
}
@ -1594,7 +1542,7 @@ void Widget::updateControlsVisibility(bool fast) {
if (_chatFilters) {
_chatFilters->setVisible(!_openedForum);
}
if (_openedFolder || _openedForum || _openedMonoforum) {
if (_openedFolder || _openedForum) {
_subsectionTopBar->show();
if (_forumTopShadow) {
_forumTopShadow->show();
@ -1973,29 +1921,6 @@ void Widget::changeOpenedForum(Data::Forum *forum, anim::type animated) {
}, (forum != nullptr), animated);
}
void Widget::changeOpenedMonoforum(
Data::SavedMessages *monoforum,
anim::type animated) {
if (_openedMonoforum == monoforum) {
return;
}
changeOpenedSubsection([&] {
cancelSearch({ .forceFullCancel = true });
closeChildList(anim::type::instant);
_openedMonoforum = monoforum;
_searchState.tab = monoforum
? ChatSearchTab::ThisPeer
: ChatSearchTab::MyMessages;
_searchWithPostsPreview = computeSearchWithPostsPreview();
_api.request(base::take(_topicSearchRequest)).cancel();
_inner->changeOpenedMonoforum(monoforum);
storiesToggleExplicitExpand(false);
updateFrozenAccountBar();
updateTopBarSuggestions();
updateStoriesVisibility();
}, (monoforum != nullptr), animated);
}
void Widget::hideChildList() {
if (_childList) {
controller()->closeForum();
@ -2003,7 +1928,7 @@ void Widget::hideChildList() {
}
void Widget::refreshTopBars() {
if (_openedFolder || _openedForum || _openedMonoforum) {
if (_openedFolder || _openedForum) {
if (!_subsectionTopBar) {
_subsectionTopBar.create(this, controller());
if (_stories) {
@ -2033,12 +1958,10 @@ void Widget::refreshTopBars() {
}
const auto history = _openedForum
? _openedForum->history().get()
: _openedMonoforum
? session().data().history(_openedMonoforum->parentChat()).get()
: nullptr;
_subsectionTopBar->setActiveChat(
HistoryView::TopBarWidget::ActiveChat{
.key = ((_openedForum || _openedMonoforum)
.key = (_openedForum
? Dialogs::Key(history)
: Dialogs::Key(_openedFolder)),
.section = Dialogs::EntryState::Section::ChatsList,
@ -2204,10 +2127,6 @@ Data::Forum *Widget::openedForum() const {
return _openedForum;
}
Data::SavedMessages *Widget::openedMonoforum() const {
return _openedMonoforum;
}
void Widget::jumpToTop(bool belowPinned) {
if (session().supportMode()) {
return;
@ -2506,15 +2425,6 @@ void Widget::escape() {
} else if (initial != forum) {
controller()->showForum(initial);
}
} else if (const auto monoforum
= controller()->shownMonoforum().current()) {
const auto id = controller()->windowId(); // #TODO monoforum
const auto initial = (Data::SavedMessages*)nullptr;
if (!initial) {
controller()->closeMonoforum();
} else if (initial != monoforum) {
controller()->showMonoforum(initial);
}
} else if (controller()->openedFolder().current()) {
if (!controller()->windowId().folder()) {
controller()->closeFolder();
@ -3379,33 +3289,12 @@ void Widget::showForum(
return;
}
cancelSearch({ .forceFullCancel = true });
openChildList(forum, nullptr, params);
}
void Widget::showMonoforum(
not_null<Data::SavedMessages*> monoforum,
const Window::SectionShow &params) {
if (_openedMonoforum == monoforum) {
return;
}
const auto nochat = !controller()->mainSectionShown();
if (!params.childColumn
|| (Core::App().settings().dialogsWidthRatio(nochat) == 0.)
|| (_layout != Layout::Main)
|| OptionForumHideChatsList.value()) {
changeOpenedMonoforum(monoforum, params.animated);
return;
}
cancelSearch({ .forceFullCancel = true });
openChildList(nullptr, monoforum, params);
openChildList(forum, params);
}
void Widget::openChildList(
Data::Forum *forum,
Data::SavedMessages *monoforum,
not_null<Data::Forum*> forum,
const Window::SectionShow &params) {
Expects(forum || monoforum);
auto slide = Window::SectionSlideParams();
const auto animated = !_childList
&& (params.animated == anim::type::normal);
@ -3426,13 +3315,8 @@ void Widget::openChildList(
this,
controller(),
Layout::Child);
if (forum) {
_childList->showForum(forum, copy);
_childListPeerId = forum->channel()->id;
} else {
_childList->showMonoforum(monoforum, copy);
_childListPeerId = monoforum->parentChat()->id;
}
_childList->showForum(forum, copy);
_childListPeerId = forum->channel()->id;
}
_childListShadow = std::make_unique<Ui::RpWidget>(this);
@ -4289,10 +4173,6 @@ PeerData *Widget::searchInPeer() const {
? nullptr
: _openedForum
? _openedForum->channel().get()
: _openedMonoforum
? (_openedMonoforum->parentChat()
? _openedMonoforum->parentChat()
: (PeerData*)session().user().get())
: _searchState.inChat.sublist()
? _searchState.inChat.sublist()->owningHistory()->peer.get()
: _searchState.inChat.peer();

View file

@ -23,7 +23,6 @@ class Error;
namespace Data {
class Forum;
class SavedMessages;
enum class StorySourcesList : uchar;
struct ReactionId;
} // namespace Data
@ -109,14 +108,10 @@ public:
void showForum(
not_null<Data::Forum*> forum,
const Window::SectionShow &params);
void showMonoforum(
not_null<Data::SavedMessages*> monoforum,
const Window::SectionShow &params);
void setInnerFocus(bool unfocusSearch = false);
[[nodiscard]] bool searchHasFocus() const;
[[nodiscard]] Data::Forum *openedForum() const;
[[nodiscard]] Data::SavedMessages *openedMonoforum() const;
void jumpToTop(bool belowPinned = false);
void raiseWithTooltip();
@ -254,9 +249,6 @@ private:
anim::type animated);
void changeOpenedFolder(Data::Folder *folder, anim::type animated);
void changeOpenedForum(Data::Forum *forum, anim::type animated);
void changeOpenedMonoforum(
Data::SavedMessages *monoforum,
anim::type animated);
void hideChildList();
void destroyChildListCanvas();
[[nodiscard]] QPixmap grabForFolderSlideAnimation();
@ -266,8 +258,7 @@ private:
Window::SlideDirection direction);
void openChildList(
Data::Forum *forum,
Data::SavedMessages *monoforum,
not_null<Data::Forum*> forum,
const Window::SectionShow &params);
void closeChildList(anim::type animated);
@ -343,7 +334,7 @@ private:
Ui::SlideWrap<Ui::RpWidget> *_topBarSuggestion = nullptr;
rpl::event_stream<int> _topBarSuggestionHeightChanged;
rpl::event_stream<bool> _searchStateForTopBarSuggestion;
rpl::event_stream<bool> _openedFolderOrForumOrMonoforumChanges;
rpl::event_stream<bool> _openedFolderOrForumChanges;
object_ptr<Ui::ElasticScroll> _scroll;
QPointer<InnerWidget> _inner;
@ -369,7 +360,6 @@ private:
Data::Folder *_openedFolder = nullptr;
Data::Forum *_openedForum = nullptr;
Data::SavedMessages *_openedMonoforum = nullptr;
SearchState _searchState;
History *_searchInMigrated = nullptr;
rpl::lifetime _searchTagsLifetime;

View file

@ -773,10 +773,6 @@ void TopBarWidget::backClicked() {
&& _activeChat.key.history()
&& _activeChat.key.history()->isForum()) {
_controller->closeForum();
} else if (_activeChat.section == Section::ChatsList
&& _activeChat.key.history()
&& _activeChat.key.history()->amMonoforumAdmin()) {
_controller->closeMonoforum();
} else {
_controller->showBackFromStack();
}

View file

@ -58,7 +58,7 @@ SublistsWidget::SublistsWidget(
this,
controller->parentController(),
rpl::single(Dialogs::InnerWidget::ChildListShown())));
_list->showSavedSublists(nullptr);
_list->showSavedSublists();
_list->setNarrowRatio(0.);
_list->chosenRow() | rpl::start_with_next([=](Dialogs::ChosenRow row) {

View file

@ -1594,18 +1594,6 @@ void MainWidget::showForum(
}
}
void MainWidget::showMonoforum(
not_null<Data::SavedMessages*> monoforum,
const SectionShow &params) {
Expects(_dialogs != nullptr);
_dialogs->showMonoforum(monoforum, params);
if (params.activation != anim::activation::background) {
_controller->window().hideSettingsAndLayer();
}
}
PeerData *MainWidget::peer() const {
return _history->peer();
}

View file

@ -199,9 +199,6 @@ public:
not_null<const HistoryItem*> item,
const SectionShow &params);
void showForum(not_null<Data::Forum*> forum, const SectionShow &params);
void showMonoforum(
not_null<Data::SavedMessages*> monoforum,
const SectionShow &params);
bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo);

View file

@ -605,15 +605,10 @@ void SessionNavigation::showPeerByLinkResolved(
showPeerInfo(peer, params);
} else if (resolveType == ResolveType::HashtagSearch) {
searchMessages(info.text, peer->owner().history(peer));
} else if ((peer->isForum() || peer->amMonoforumAdmin())
&& resolveType != ResolveType::Boost) {
} else if (peer->isForum() && resolveType != ResolveType::Boost) {
const auto itemId = info.messageId;
if (!itemId) {
if (peer->isForum()) {
parentController()->showForum(peer->forum(), params);
} else {
parentController()->showMonoforum(peer->monoforum(), params);
}
parentController()->showForum(peer->forum(), params);
} else if (const auto item = peer->owner().message(peer, itemId)) {
showMessageByLinkResolved(item, info);
} else {
@ -1929,7 +1924,6 @@ void SessionController::showForum(
}
}, _shownForumLifetime);
content()->showForum(forum, params);
closeMonoforum();
}
void SessionController::closeForum() {
@ -1980,57 +1974,6 @@ const rpl::variable<Data::Forum*> &SessionController::shownForum() const {
return _shownForum;
}
void SessionController::showMonoforum(
not_null<Data::SavedMessages*> monoforum,
const SectionShow &params) {
// if (showForumInDifferentWindow(forum, params)) {
// return;
// }
_shownMonoforumLifetime.destroy();
if (_shownMonoforum.current() != monoforum) {
resetFakeUnreadWhileOpened();
}
if (monoforum
&& _activeChatEntry.current().key.peer()
&& adaptive().isOneColumn()) {
clearSectionStack(params);
}
_shownMonoforum = monoforum.get();
if (_shownMonoforum.current() != monoforum) {
return;
}
monoforum->destroyed(
) | rpl::start_with_next([=] {
closeMonoforum();
}, _shownMonoforumLifetime);
content()->showMonoforum(monoforum, params);
closeForum();
}
void SessionController::closeMonoforum() {
if (const auto monoforum = _shownMonoforum.current()) {
const auto id = windowId();
if (id.type == SeparateType::SavedSublist) {
const auto initial = id.parentChat;
if (!initial
|| !initial->monoforum()
|| initial == monoforum->parentChat()) {
Core::App().closeWindow(_window);
} else {
showMonoforum(initial->monoforum());
}
return;
}
}
_shownMonoforumLifetime.destroy();
_shownMonoforum = nullptr;
}
auto SessionController::shownMonoforum() const
-> const rpl::variable<Data::SavedMessages*> & {
return _shownMonoforum;
}
void SessionController::setActiveChatEntry(Dialogs::RowDescriptor row) {
if (windowId().type == SeparateType::SharedMedia) {
return;

View file

@ -415,12 +415,6 @@ public:
void closeForum();
const rpl::variable<Data::Forum*> &shownForum() const;
void showMonoforum(
not_null<Data::SavedMessages*> monoforum,
const SectionShow &params = SectionShow::Way::ClearStack);
void closeMonoforum();
const rpl::variable<Data::SavedMessages*> &shownMonoforum() const;
void setActiveChatEntry(Dialogs::RowDescriptor row);
void setActiveChatEntry(Dialogs::Key key);
Dialogs::RowDescriptor activeChatEntryCurrent() const;
@ -770,8 +764,6 @@ private:
rpl::variable<Data::Folder*> _openedFolder;
rpl::variable<Data::Forum*> _shownForum;
rpl::lifetime _shownForumLifetime;
rpl::variable<Data::SavedMessages*> _shownMonoforum;
rpl::lifetime _shownMonoforumLifetime;
rpl::event_stream<> _filtersMenuChanged;

@ -1 +1 @@
Subproject commit 369d8b5172b6f70a3a9b2363cfa0f4fc5f620f56
Subproject commit 2b0d129b528bb56a71ebcf1f8c0a4d8b19123e34