Add three-dot menu with Search to community top bar

This commit is contained in:
John Preston
2026-07-09 17:21:27 +04:00
parent 9b72c0f819
commit 1ae92b5fe8
4 changed files with 45 additions and 4 deletions
+2
View File
@@ -1909,6 +1909,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_manage_group_title" = "Manage group";
"lng_manage_channel_title" = "Manage Channel";
"lng_manage_community_title" = "Manage community";
"lng_manage_bot_title" = "Manage Bot";
"lng_manage_peer_recent_actions" = "Recent actions";
"lng_manage_peer_star_ref" = "Affiliate programs";
@@ -5229,6 +5230,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_context_send_message" = "Send message";
"lng_context_view_group" = "View group info";
"lng_context_view_channel" = "View channel info";
"lng_context_view_community" = "View community info";
"lng_context_view_topic" = "View topic info";
"lng_context_view_thread" = "View thread info";
"lng_context_hide_psa" = "Hide this announcement";
@@ -1807,6 +1807,13 @@ void Widget::setupShortcuts() {
controller()->searchInChat(_openedFolder);
}
return true;
} else if (const auto community = _openedCommunity) {
if (!_subsectionTopBar->searchSetFocus()) {
const auto history = session().data().history(
community->channel());
controller()->searchInChat(history);
}
return true;
} else if (!_childList && _search->isVisible()) {
_search->setFocus();
return true;
@@ -2669,6 +2676,7 @@ void Widget::updateStoriesVisibility() {
&& (!_suggestions || !_hidingSuggestions.empty());
const auto hiddenInstant = _showAnimation
|| _openedForum
|| _openedCommunity
|| (widthAnimation && !suggestionsAnimation)
|| _childList
|| _stories->empty()
@@ -3891,7 +3899,11 @@ bool Widget::applySearchState(SearchState state) {
const auto topic = state.inChat.topic();
const auto forum = peer ? peer->forum() : nullptr;
const auto folder = state.inChat.folder();
if (folder || (forum && !topic)) {
const auto community = (_openedCommunity
&& peer == _openedCommunity->channel())
? _openedCommunity
: nullptr;
if (folder || (forum && !topic) || community) {
state.inChat = {};
}
if (!state.inChat && !forum && !_openedForum) {
@@ -3950,7 +3962,7 @@ bool Widget::applySearchState(SearchState state) {
} else {
return false;
}
} else if (folder && folder == _openedFolder) {
} else if ((folder && folder == _openedFolder) || community) {
showSearchInTopBar(anim::type::normal);
} else if (peer && (_layout != Layout::Main)) {
return false;
@@ -1318,7 +1318,8 @@ void TopBarWidget::updateControlsVisibility() {
? (hasPollsMenu || hasTodoListsMenu || hasTopicMenu)
: (section == Section::ChatsList)
? (_activeChat.key.folder()
|| (_activeChat.key.peer() && _activeChat.key.peer()->isForum()))
|| (_activeChat.key.peer() && _activeChat.key.peer()->isForum())
|| communityChatsListBar())
: (section == Section::SavedSublist)
? (_activeChat.key.peer()
&& _activeChat.key.peer()->isChannel()
@@ -120,6 +120,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "export/export_manager.h"
#include "boxes/peers/edit_participants_box.h"
#include "boxes/peers/edit_peer_info_box.h"
#include "boxes/peers/manage_community_box.h"
#include "boxes/premium_preview_box.h"
#include "styles/style_chat.h"
#include "styles/style_chat_helpers.h"
@@ -295,6 +296,7 @@ private:
using Section = Dialogs::EntryState::Section;
void fillChatsListActions();
void fillCommunityChatsListActions();
void fillHistoryActions();
void fillProfileActions();
void fillRepliesActions();
@@ -1785,8 +1787,32 @@ void Filler::addSearchTopics() {
}, &st::menuIconSearch);
}
void Filler::fillCommunityChatsListActions() {
const auto channel = _peer ? _peer->asChannel() : nullptr;
const auto history = _request.key.history();
if (!channel || !history) {
return;
}
const auto controller = _controller;
_addAction(tr::lng_context_view_community(tr::now), [=] {
controller->showPeerInfo(channel);
}, &st::menuIconInfo);
_addAction(tr::lng_dlg_filter(tr::now), [=] {
controller->searchInChat(history);
}, &st::menuIconSearch);
if (channel->canManageLinkedPeers()) {
_addAction(tr::lng_manage_community_title(tr::now), [=] {
ShowManageCommunityBox(controller, channel);
}, &st::menuIconManage);
}
}
void Filler::fillChatsListActions() {
if (!_peer || !_peer->isForum()) {
const auto channel = _peer ? _peer->asChannel() : nullptr;
if (channel && channel->isCommunity()) {
fillCommunityChatsListActions();
return;
} else if (!_peer || !_peer->isForum()) {
return;
}
addCreateTopic();