2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 14:17:45 +00:00

[Improvement] Allow to search messages from user

This commit is contained in:
RadRussianRus
2022-09-10 20:46:20 +03:00
committed by Eric Kotato
parent f6431aa08b
commit cbda1d7d39
7 changed files with 50 additions and 7 deletions

View File

@@ -84,6 +84,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_tray_icon": "Tray icon",
"ktg_settings_tray_icon_default": "Default",
"ktg_settings_tray_icon_blue": "Blue",

View File

@@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/peers/edit_participants_box.h"
#include "kotato/kotato_lang.h"
#include "core/application.h"
#include "api/api_chat_participants.h"
#include "boxes/peers/edit_participant_box.h"
#include "boxes/peers/add_participants_box.h"
@@ -20,6 +22,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/mtproto_config.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"
#include "data/data_session.h"
@@ -32,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/outline_segments.h"
#include "ui/widgets/popup_menu.h"
#include "info/profile/info_profile_values.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h"
#include "history/history.h"
#include "styles/style_menu_icons.h"
@@ -1630,6 +1635,20 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
? &st::menuIconProfile
: &st::menuIconInfo));
}
if (const auto window = _navigation->parentController()) {
if (const auto mainwidget = window->widget()->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 (const auto by = _additional.restrictedBy(participant)) {
result->addAction(
(_role == Role::Kicked

View File

@@ -41,6 +41,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 "api/api_chat_filters.h"
#include "apiwrap.h"
@@ -2088,7 +2089,10 @@ void Widget::showMainMenu() {
controller()->widget()->showMainMenu();
}
void Widget::searchMessages(QString query, Key inChat) {
void Widget::searchMessages(
QString query,
Key inChat,
UserData *from) {
if (_childList) {
const auto forum = controller()->shownForum().current();
const auto topic = inChat.topic();
@@ -2138,13 +2142,19 @@ void Widget::searchMessages(QString query, Key inChat) {
cancelSearch();
setSearchInChat(inChat, nullptr, tags);
}
setSearchQuery(query);
if (!query.trimmed().isEmpty()) {
setSearchQuery(query);
}
applySearchUpdate(true);
_searchTimer.cancel();
searchMessages();
session().local().saveRecentSearchHashtags(query);
}
if (inChat && from) {
setSearchInChat(inChat, from);
applySearchUpdate(true);
}
}
void Widget::searchTopics() {

View File

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

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 "chat_helpers/stickers_emoji_pack.h"
#include "core/file_utilities.h"
#include "core/click_handler_types.h"
@@ -2162,6 +2164,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);
}
if (!item->isService()
&& peerIsChannel(itemId.peer)
&& !_peer->isMegagroup()) {

View File

@@ -731,9 +731,9 @@ void MainWidget::hideSingleUseKeyboard(FullMsgId replyToId) {
_history->hideSingleUseKeyboard(replyToId);
}
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat, UserData *from) {
if (controller()->isPrimary()) {
_dialogs->searchMessages(query, inChat);
_dialogs->searchMessages(query, inChat, from);
if (isOneColumn()) {
_controller->clearSectionStack();
} else {
@@ -753,7 +753,7 @@ void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
const auto account = &session().account();
if (const auto window = Core::App().windowFor(account)) {
if (const auto controller = window->sessionController()) {
controller->content()->searchMessages(query, inChat);
controller->content()->searchMessages(query, inChat, from);
controller->widget()->activate();
}
}

View File

@@ -185,7 +185,7 @@ public:
void sendBotCommand(Bot::SendCommandRequest request);
void hideSingleUseKeyboard(FullMsgId replyToId);
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,