[Improvement] Allow to search messages from user

This commit is contained in:
Eric Kotato 2022-09-10 20:46:20 +03:00 committed by Eric Kotato
parent 35c9a61316
commit bebf2d9f2f
8 changed files with 46 additions and 6 deletions

View file

@ -104,6 +104,7 @@
"ktg_hide_pinned_message": "Hide",
"ktg_stickers_copy_title": "Copy name",
"ktg_stickers_title_copied": "Sticker pack name copied to clipboard.",
"ktg_context_show_messages_from": "User messages",
"ktg_settings_userpic_rounding": "Profile pictures rounding",
"ktg_settings_userpic_rounding_none": "Square",
"ktg_settings_userpic_rounding_small": "Small",

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/peers/edit_participants_box.h"
#include "kotato/kotato_lang.h"
#include "api/api_chat_participants.h"
#include "boxes/peer_list_controllers.h"
#include "boxes/peers/edit_participant_box.h"
@ -17,8 +18,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/add_contact_box.h"
#include "main/main_session.h"
#include "mtproto/mtproto_config.h"
#include "facades.h"
#include "apiwrap.h"
#include "lang/lang_keys.h"
#include "mainwindow.h"
#include "mainwidget.h"
#include "dialogs/dialogs_indexed_list.h"
#include "data/data_peer_values.h"
@ -1545,6 +1548,20 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
? &st::menuIconProfile
: &st::menuIconInfo));
}
if (const auto window = App::wnd()) {
if (const auto mainwidget = window->sessionContent()) {
result->addAction(
ktr("ktg_context_show_messages_from"),
crl::guard(this, [=] {
mainwidget->searchMessages(
" ",
(_peer && !_peer->isUser())
? _peer->owner().history(_peer).get()
: Dialogs::Key(),
user);
}), &st::menuIconSearch);
}
}
if (_role == Role::Kicked) {
if (_peer->isMegagroup()
&& _additional.canRestrictParticipant(participant)) {

View file

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h"
#include "main/main_domain.h"
#include "main/main_session.h"
#include "main/main_account.h"
#include "main/main_session_settings.h"
#include "apiwrap.h"
#include "base/event_filter.h"
@ -1059,7 +1060,8 @@ void Widget::showMainMenu() {
void Widget::searchMessages(
const QString &query,
Key inChat) {
Key inChat,
UserData *from) {
auto inChatChanged = [&] {
if (inChat == _searchInChat) {
return false;
@ -1075,7 +1077,9 @@ void Widget::searchMessages(
cancelSearch();
setSearchInChat(inChat);
}
_filter->setText(query);
if (!query.trimmed().isEmpty()) {
_filter->setText(query);
}
_filter->updatePlaceholder();
applyFilterUpdate(true);
_searchTimer.cancel();
@ -1083,6 +1087,10 @@ void Widget::searchMessages(
session().local().saveRecentSearchHashtags(query);
}
if (inChat && from) {
setSearchInChat(inChat, from);
applyFilterUpdate(true);
}
}
void Widget::searchMore() {

View file

@ -83,7 +83,7 @@ public:
void scrollToEntry(const RowDescriptor &entry);
void searchMessages(const QString &query, Key inChat = {});
void searchMessages(const QString &query, Key inChat = {}, UserData *from = nullptr);
void searchMore();
void updateForwardBar();

View file

@ -8,6 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_inner_widget.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_lang.h"
#include "mainwidget.h"
#include "core/file_utilities.h"
#include "core/crash_reports.h"
#include "core/click_handler_types.h"
@ -2079,6 +2081,17 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
Window::ToggleMessagePinned(controller, pinItemId, !isPinned);
}), isPinned ? &st::menuIconUnpin : &st::menuIconPin);
}
const auto peer = item->history()->peer;
if (peer->isChat() || peer->isMegagroup()) {
_menu->addAction(ktr("ktg_context_show_messages_from"), [=] {
controller->content()->searchMessages(
" ",
(peer && !peer->isUser())
? peer->owner().history(peer).get()
: Dialogs::Key(),
item->from()->asUser());
}, &st::menuIconSearch);
}
};
const auto addPhotoActions = [&](not_null<PhotoData*> photo, HistoryItem *item) {
const auto media = photo->activeMediaView();

View file

@ -790,12 +790,12 @@ void MainWidget::hideSingleUseKeyboard(PeerData *peer, MsgId replyTo) {
_history->hideSingleUseKeyboard(peer, replyTo);
}
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat, UserData *from) {
// #TODO windows
if (!_dialogs) {
return;
}
_dialogs->searchMessages(query, inChat);
_dialogs->searchMessages(query, inChat, from);
if (isOneColumn()) {
Ui::showChatsList(&session());
} else {

View file

@ -184,7 +184,7 @@ public:
void sendBotCommand(Bot::SendCommandRequest request);
void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo);
void searchMessages(const QString &query, Dialogs::Key inChat);
void searchMessages(const QString &query, Dialogs::Key inChat, UserData *from = nullptr);
void setChatBackground(
const Data::WallPaper &background,

View file

@ -76,6 +76,7 @@ menuIconFake: icon {{ "menu/fake", menuIconColor }};
menuIconPersonal: icon {{ "menu/personal", menuIconColor }};
menuIconPorn: icon {{ "menu/porn", menuIconColor }};
menuIconViolence: icon {{ "menu/violence", menuIconColor }};
menuIconSearch: icon {{ "menu/search", menuIconColor }};
menuIconHide: icon {{ "menu/hide", menuIconColor }};
menuIconMuteFor: icon {{ "menu/mute_for", menuIconColor }};
menuIconSilent: icon {{ "menu/silent", menuIconColor }};