MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / searchMessages

Method searchMessages

Telegram/SourceFiles/mainwidget.cpp:794–855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792}
793
794void MainWidget::searchMessages(
795 const QString &query,
796 Dialogs::Key inChat,
797 PeerData *searchFrom) {
798 const auto complex = Data::HashtagWithUsernameFromQuery(query);
799 if (!complex.username.isEmpty()) {
800 _controller->showPeerByLink(Window::PeerByLinkInfo{
801 .usernameOrId = complex.username,
802 .text = complex.hashtag,
803 .resolveType = Window::ResolveType::HashtagSearch,
804 });
805 return;
806 }
807 auto tags = Data::SearchTagsFromQuery(query);
808 const auto archiveWindow = (_controller->windowId().type
809 == Window::SeparateType::Archive);
810 if (_dialogs
811 && !archiveWindow
812 && (!ForceComposeSearchOneColumn.value() || !isOneColumn())) {
813 auto state = Dialogs::SearchState{
814 .inChat = ((tags.empty() || inChat.sublist())
815 ? inChat
816 : session().data().history(session().user())),
817 .fromPeer = inChat ? searchFrom : nullptr,
818 .tags = tags,
819 .query = tags.empty() ? query : QString(),
820 };
821 state.tab = state.defaultTabForMe();
822 _dialogs->searchMessages(std::move(state));
823 if (isOneColumn()) {
824 _controller->clearSectionStack();
825 } else {
826 _dialogs->setInnerFocus();
827 }
828 } else {
829 if (const auto sublist = inChat.sublist()) {
830 using namespace HistoryView;
831 controller()->showSection(
832 std::make_shared<ChatMemento>(ChatViewId{
833 .history = sublist->owningHistory(),
834 .sublist = sublist,
835 }));
836 } else if (!tags.empty()) {
837 inChat = controller()->session().data().history(
838 controller()->session().user());
839 }
840 if ((!_mainSection
841 || !_mainSection->searchInChatEmbedded(query, inChat, searchFrom))
842 && !_history->searchInChatEmbedded(query, inChat, searchFrom)) {
843 const auto account = not_null(&session().account());
844 if (const auto window = Core::App().windowFor(account)) {
845 if (const auto controller = window->sessionController()) {
846 controller->widget()->activate();
847 controller->content()->searchMessages(
848 query,
849 inChat,
850 searchFrom);
851 }

Callers 1

searchByHashtagFunction · 0.45

Calls 15

SearchTagsFromQueryFunction · 0.85
AppClass · 0.85
showPeerByLinkMethod · 0.80
defaultTabForMeMethod · 0.80
clearSectionStackMethod · 0.80
windowForMethod · 0.80
QStringClass · 0.50
isEmptyMethod · 0.45
windowIdMethod · 0.45
valueMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected