[Improvement] Allow to search messages from user

This commit is contained in:
Eric Kotato 2022-09-10 20:46:20 +03:00
parent 010681e600
commit c078d410a9
8 changed files with 45 additions and 6 deletions

View file

@ -108,6 +108,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"
@ -1538,6 +1541,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

@ -25,6 +25,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"
@ -992,7 +993,8 @@ void Widget::showMainMenu() {
void Widget::searchMessages(
const QString &query,
Key inChat) {
Key inChat,
UserData *from) {
auto inChatChanged = [&] {
if (inChat == _searchInChat) {
return false;
@ -1008,7 +1010,9 @@ void Widget::searchMessages(
onCancelSearch();
setSearchInChat(inChat);
}
_filter->setText(query);
if (!query.trimmed().isEmpty()) {
_filter->setText(query);
}
_filter->updatePlaceholder();
applyFilterUpdate(true);
_searchTimer.stop();
@ -1016,6 +1020,10 @@ void Widget::searchMessages(
session().local().saveRecentSearchHashtags(query);
}
if (inChat && from) {
setSearchInChat(inChat, from);
applyFilterUpdate(true);
}
}
void Widget::onSearchMore() {

View file

@ -84,7 +84,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 onSearchMore();
void updateForwardBar();

View file

@ -8,6 +8,7 @@ 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 "core/file_utilities.h"
#include "core/crash_reports.h"
#include "core/click_handler_types.h"
@ -1970,6 +1971,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

@ -781,12 +781,12 @@ bool MainWidget::insertBotCommand(const QString &cmd) {
return _history->insertBotCommand(cmd);
}
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

@ -188,7 +188,7 @@ public:
void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo);
bool insertBotCommand(const QString &cmd);
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

@ -86,6 +86,7 @@ menuIconImportTheme: icon {{ "menu/import_theme", menuSubmenuArrowFg }};
menuIconExportTheme: icon {{ "menu/export_theme", menuSubmenuArrowFg }};
menuIconRestore: icon {{ "menu/restore", menuSubmenuArrowFg }};
menuIconSettings: icon {{ "menu/settings", menuSubmenuArrowFg }};
menuIconSearch: icon {{ "menu/search", menuSubmenuArrowFg }};
menuIconHide: icon {{ "menu/hide", menuSubmenuArrowFg }};
mediaMenuIconStickers: icon {{ "menu/stickers", mediaviewMenuFg }};