Add "Show Topics List" button to topic profile.

This commit is contained in:
John Preston 2022-11-08 20:27:12 +04:00
parent d0d2a4f488
commit 4a8b5c3015
3 changed files with 34 additions and 3 deletions

View File

@ -3559,6 +3559,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_forum_no_messages" = "No messages";
"lng_forum_messages#one" = "{count} message";
"lng_forum_messages#other" = "{count} messages";
"lng_forum_show_topics_list" = "Show Topics List";
// Wnd specific

View File

@ -194,6 +194,7 @@ private:
object_ptr<Ui::RpWidget> setupInfo();
object_ptr<Ui::RpWidget> setupMuteToggle();
void setupMainButtons();
Ui::MultiSlideTracker fillTopicButtons();
Ui::MultiSlideTracker fillUserButtons(
not_null<UserData*> user);
Ui::MultiSlideTracker fillChannelButtons(
@ -538,11 +539,15 @@ void DetailsFiller::setupMainButtons() {
auto tracker = callback();
topSkip->toggleOn(std::move(tracker).atLeastOneShownValue());
};
if (auto user = _peer->asUser()) {
if (_topic) {
wrapButtons([=] {
return fillTopicButtons();
});
} else if (const auto user = _peer->asUser()) {
wrapButtons([=] {
return fillUserButtons(user);
});
} else if (auto channel = _peer->asChannel()) {
} else if (const auto channel = _peer->asChannel()) {
if (!channel->isMegagroup()) {
wrapButtons([=] {
return fillChannelButtons(channel);
@ -551,6 +556,26 @@ void DetailsFiller::setupMainButtons() {
}
}
Ui::MultiSlideTracker DetailsFiller::fillTopicButtons() {
using namespace rpl::mappers;
Ui::MultiSlideTracker tracker;
const auto window = _controller->parentController();
const auto channel = _topic->channel().get();
auto showTopicsVisible = rpl::combine(
window->adaptive().oneColumnValue(),
window->openedForum().value(),
_1 || (_2 != channel));
AddMainButton(
_wrap,
tr::lng_forum_show_topics_list(),
std::move(showTopicsVisible),
[=] { window->openForum(channel); },
tracker);
return tracker;
}
Ui::MultiSlideTracker DetailsFiller::fillUserButtons(
not_null<UserData*> user) {
using namespace rpl::mappers;

View File

@ -983,7 +983,9 @@ void SessionController::openForum(
if (_openedForum.current() != forum) {
resetFakeUnreadWhileOpened();
}
if (forum && _activeChatEntry.current().key.peer()) {
if (forum
&& _activeChatEntry.current().key.peer()
&& adaptive().isOneColumn()) {
clearSectionStack(params);
}
_openedForum = forum.get();
@ -996,6 +998,9 @@ void SessionController::openForum(
{ anim::type::normal, anim::activation::background });
}, _openedForumLifetime);
}
if (params.activation != anim::activation::background) {
hideLayer();
}
}
void SessionController::closeForum() {