Fix new forum layout search and topics list.

This commit is contained in:
John Preston 2025-06-05 13:55:55 +04:00
parent 08681ac1b9
commit 65cfd6c81c
4 changed files with 64 additions and 16 deletions

View file

@ -3516,7 +3516,10 @@ bool Widget::applySearchState(SearchState state) {
showSearchInTopBar(anim::type::normal);
} else if (_layout == Layout::Main) {
_forumSearchRequested = true;
controller()->showForum(forum);
auto params = Window::SectionShow(
Window::SectionShow::Way::ClearStack);
params.forceTopicsList = true;
controller()->showForum(forum, params);
} else {
return false;
}
@ -4345,6 +4348,19 @@ bool Widget::cancelSearch(CancelSearchOptions options) {
}
}
updateForceDisplayWide();
if (clearingInChat) {
if (const auto forum = controller()->shownForum().current()) {
if (forum->channel()->useSubsectionTabs()) {
const auto id = controller()->windowId();
const auto initial = id.forum();
if (!initial) {
controller()->closeForum();
} else if (initial != forum) {
controller()->showForum(initial);
}
}
}
}
return clearingQuery || clearingInChat || clearSearchFocus;
}

View file

@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_folder.h"
#include "data/data_forum.h"
#include "data/data_forum_topic.h"
#include "data/data_peer_values.h"
#include "data/data_session.h"
@ -1040,6 +1041,9 @@ private:
not_null<ChannelData*> channel);
Ui::MultiSlideTracker fillDiscussionButtons(
not_null<ChannelData*> channel);
void addShowTopicsListButton(
Ui::MultiSlideTracker &tracker,
not_null<Data::Forum*> forum);
void addReportReaction(Ui::MultiSlideTracker &tracker);
void addReportReaction(
@ -2103,23 +2107,37 @@ void DetailsFiller::addReportReaction(
}
Ui::MultiSlideTracker DetailsFiller::fillTopicButtons() {
Ui::MultiSlideTracker tracker;
addShowTopicsListButton(tracker, _topic->forum());
return tracker;
}
void DetailsFiller::addShowTopicsListButton(
Ui::MultiSlideTracker &tracker,
not_null<Data::Forum*> forum) {
using namespace rpl::mappers;
Ui::MultiSlideTracker tracker;
const auto window = _controller->parentController();
const auto forum = _topic->forum();
const auto channel = forum->channel();
auto showTopicsVisible = rpl::combine(
window->adaptive().oneColumnValue(),
window->shownForum().value(),
_1 || (_2 != forum));
const auto callback = [=] {
if (const auto forum = channel->forum()) {
if (channel->useSubsectionTabs()) {
window->searchInChat(forum->history());
} else {
window->showForum(forum);
}
}
};
AddMainButton(
_wrap,
tr::lng_forum_show_topics_list(),
std::move(showTopicsVisible),
[=] { window->showForum(forum); },
callback,
tracker);
return tracker;
}
Ui::MultiSlideTracker DetailsFiller::fillUserButtons(
@ -2216,6 +2234,12 @@ Ui::MultiSlideTracker DetailsFiller::fillDiscussionButtons(
std::move(viewDiscussion),
tracker);
if (const auto forum = channel->forum()) {
if (channel->useSubsectionTabs()) {
addShowTopicsListButton(tracker, forum);
}
}
return tracker;
}

View file

@ -1876,9 +1876,10 @@ bool SessionController::showForumInDifferentWindow(
void SessionController::showForum(
not_null<Data::Forum*> forum,
const SectionShow &params) {
const auto forced = params.forceTopicsList;
if (showForumInDifferentWindow(forum, params)) {
return;
} else if (forum->channel()->useSubsectionTabs()) {
} else if (!forced && forum->channel()->useSubsectionTabs()) {
if (const auto active = forum->activeSubsectionThread()) {
showThread(active, ShowAtUnreadMsgId, params);
} else {
@ -1914,20 +1915,26 @@ void SessionController::showForum(
});
}
};
content()->showForum(forum, params);
if (_shownForum.current() != forum) {
return;
}
forum->destroyed(
) | rpl::start_with_next([=] {
closeAndShowHistory(false);
}, _shownForumLifetime);
using FlagChange = Data::Flags<ChannelDataFlags>::Change;
forum->channel()->flagsValue(
) | rpl::start_with_next([=](FlagChange change) {
if (change.diff & ChannelDataFlag::ForumTabs) {
if (HistoryView::SubsectionTabs::UsedFor(history)) {
closeAndShowHistory(true);
if (!forced) {
using FlagChange = Data::Flags<ChannelDataFlags>::Change;
forum->channel()->flagsValue(
) | rpl::start_with_next([=](FlagChange change) {
if (change.diff & ChannelDataFlag::ForumTabs) {
if (HistoryView::SubsectionTabs::UsedFor(history)) {
closeAndShowHistory(true);
}
}
}
}, _shownForumLifetime);
content()->showForum(forum, params);
}, _shownForumLifetime);
}
}
void SessionController::closeForum() {

View file

@ -171,6 +171,7 @@ struct SectionShow {
bool thirdColumn = false;
bool childColumn = false;
bool forbidLayer = false;
bool forceTopicsList = false;
bool reapplyLocalDraft = false;
bool dropSameFromStack = false;
Origin origin;