mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Merge tag 'v4.14.6' into dev
# Conflicts: # Telegram/Resources/winrc/Telegram.rc # Telegram/Resources/winrc/Updater.rc # Telegram/SourceFiles/core/version.h # Telegram/SourceFiles/dialogs/dialogs_widget.cpp # Telegram/SourceFiles/dialogs/dialogs_widget.h # Telegram/SourceFiles/history/history_item_helpers.cpp # Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp # Telegram/lib_ui # lib/xdg/org.telegram.desktop.metainfo.xml # snap/snapcraft.yaml
This commit is contained in:
@@ -67,6 +67,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_download_manager.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_saved_sublist.h"
|
||||
#include "data/data_stories.h"
|
||||
#include "info/downloads/info_downloads_widget.h"
|
||||
#include "info/info_memento.h"
|
||||
@@ -832,7 +833,7 @@ void Widget::setupStories() {
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_stories->verticalScrollEvents(
|
||||
) | rpl::start_with_next([=](not_null<QWheelEvent*> e) {
|
||||
_scroll->viewportEvent(e);
|
||||
@@ -1733,7 +1734,7 @@ void Widget::loadMoreBlockedByDate() {
|
||||
bool Widget::searchMessages(bool searchCache) {
|
||||
auto result = false;
|
||||
auto q = currentSearchQuery().trimmed();
|
||||
if (q.isEmpty() && !_searchFromAuthor) {
|
||||
if (q.isEmpty() && !_searchFromAuthor && _searchTags.empty()) {
|
||||
cancelSearchRequest();
|
||||
_api.request(base::take(_peerSearchRequest)).cancel();
|
||||
_api.request(base::take(_topicSearchRequest)).cancel();
|
||||
@@ -1750,6 +1751,7 @@ bool Widget::searchMessages(bool searchCache) {
|
||||
if (i != _searchCache.end()) {
|
||||
_searchQuery = q;
|
||||
_searchQueryFrom = _searchFromAuthor;
|
||||
_searchQueryTags = _searchTags;
|
||||
_searchNextRate = 0;
|
||||
_searchFull = _searchFullMigrated = false;
|
||||
cancelSearchRequest();
|
||||
@@ -1761,9 +1763,12 @@ bool Widget::searchMessages(bool searchCache) {
|
||||
0);
|
||||
result = true;
|
||||
}
|
||||
} else if (_searchQuery != q || _searchQueryFrom != _searchFromAuthor) {
|
||||
} else if (_searchQuery != q
|
||||
|| _searchQueryFrom != _searchFromAuthor
|
||||
|| _searchQueryTags != _searchTags) {
|
||||
_searchQuery = q;
|
||||
_searchQueryFrom = _searchFromAuthor;
|
||||
_searchQueryTags = _searchTags;
|
||||
_searchNextRate = 0;
|
||||
_searchFull = _searchFullMigrated = false;
|
||||
cancelSearchRequest();
|
||||
@@ -1772,18 +1777,31 @@ bool Widget::searchMessages(bool searchCache) {
|
||||
auto &histories = session().data().histories();
|
||||
const auto type = Data::Histories::RequestType::History;
|
||||
const auto history = session().data().history(peer);
|
||||
const auto sublist = _openedForum
|
||||
? nullptr
|
||||
: _searchInChat.sublist();
|
||||
const auto fromPeer = sublist ? nullptr : _searchQueryFrom;
|
||||
const auto savedPeer = sublist
|
||||
? sublist->peer().get()
|
||||
: nullptr;
|
||||
_searchInHistoryRequest = histories.sendRequest(history, type, [=](Fn<void()> finish) {
|
||||
const auto type = SearchRequestType::PeerFromStart;
|
||||
using Flag = MTPmessages_Search::Flag;
|
||||
_searchRequest = session().api().request(MTPmessages_Search(
|
||||
MTP_flags((topic ? Flag::f_top_msg_id : Flag())
|
||||
| (_searchQueryFrom ? Flag::f_from_id : Flag())),
|
||||
| (fromPeer ? Flag::f_from_id : Flag())
|
||||
| (savedPeer ? Flag::f_saved_peer_id : Flag())
|
||||
| (_searchQueryTags.empty()
|
||||
? Flag()
|
||||
: Flag::f_saved_reaction)),
|
||||
peer->input,
|
||||
MTP_string(_searchQuery),
|
||||
(_searchQueryFrom
|
||||
? _searchQueryFrom->input
|
||||
: MTP_inputPeerEmpty()),
|
||||
MTPInputPeer(), // saved_peer_id
|
||||
(fromPeer ? fromPeer->input : MTP_inputPeerEmpty()),
|
||||
(savedPeer ? savedPeer->input : MTP_inputPeerEmpty()),
|
||||
MTP_vector_from_range(
|
||||
_searchQueryTags | ranges::views::transform(
|
||||
Data::ReactionToMTP
|
||||
)),
|
||||
MTP_int(topic ? topic->rootId() : 0),
|
||||
MTP_inputMessagesFilterEmpty(),
|
||||
MTP_int(0), // min_date
|
||||
@@ -1887,6 +1905,7 @@ bool Widget::searchMessages(bool searchCache) {
|
||||
bool Widget::searchForPeersRequired(const QString &query) const {
|
||||
return !_searchInChat
|
||||
&& !_searchFromAuthor
|
||||
&& _searchTags.empty()
|
||||
&& !_openedForum
|
||||
&& !query.isEmpty()
|
||||
&& (query[0] != '#');
|
||||
@@ -1895,6 +1914,7 @@ bool Widget::searchForPeersRequired(const QString &query) const {
|
||||
bool Widget::searchForTopicsRequired(const QString &query) const {
|
||||
return !_searchInChat
|
||||
&& !_searchFromAuthor
|
||||
&& _searchTags.empty()
|
||||
&& _openedForum
|
||||
&& !query.isEmpty()
|
||||
&& (query[0] != '#')
|
||||
@@ -1911,7 +1931,7 @@ void Widget::showMainMenu() {
|
||||
controller()->widget()->showMainMenu();
|
||||
}
|
||||
|
||||
void Widget::searchMessages(const QString &query, Key inChat, UserData *from) {
|
||||
void Widget::searchMessages(QString query, Key inChat, UserData *from) {
|
||||
if (_childList) {
|
||||
const auto forum = controller()->shownForum().current();
|
||||
const auto topic = inChat.topic();
|
||||
@@ -1926,6 +1946,12 @@ void Widget::searchMessages(const QString &query, Key inChat, UserData *from) {
|
||||
controller()->closeFolder();
|
||||
}
|
||||
|
||||
auto tags = std::vector<Data::ReactionId>();
|
||||
if (const auto tagId = Data::SearchTagFromQuery(query)) {
|
||||
inChat = session().data().history(session().user());
|
||||
query = QString();
|
||||
tags.push_back(tagId);
|
||||
}
|
||||
const auto inChatChanged = [&] {
|
||||
const auto inPeer = inChat.peer();
|
||||
const auto inTopic = inChat.topic();
|
||||
@@ -1938,7 +1964,7 @@ void Widget::searchMessages(const QString &query, Key inChat, UserData *from) {
|
||||
} else if ((inTopic || (inPeer && !inPeer->isForum()))
|
||||
&& (inChat == _searchInChat)) {
|
||||
return false;
|
||||
} else if (const auto inPeer = inChat.peer()) {
|
||||
} else if (inPeer) {
|
||||
if (const auto to = inPeer->migrateTo()) {
|
||||
if (to == _searchInChat.peer() && !_searchInChat.topic()) {
|
||||
return false;
|
||||
@@ -1947,10 +1973,12 @@ void Widget::searchMessages(const QString &query, Key inChat, UserData *from) {
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
if ((currentSearchQuery() != query) || inChatChanged) {
|
||||
if ((currentSearchQuery() != query)
|
||||
|| inChatChanged
|
||||
|| _searchTags != tags) {
|
||||
if (inChat) {
|
||||
cancelSearch();
|
||||
setSearchInChat(inChat);
|
||||
setSearchInChat(inChat, nullptr, tags);
|
||||
}
|
||||
setSearchQuery(query);
|
||||
applyFilterUpdate(true);
|
||||
@@ -2017,6 +2045,13 @@ void Widget::searchMore() {
|
||||
const auto topic = searchInTopic();
|
||||
const auto type = Data::Histories::RequestType::History;
|
||||
const auto history = session().data().history(peer);
|
||||
const auto sublist = _openedForum
|
||||
? nullptr
|
||||
: _searchInChat.sublist();
|
||||
const auto fromPeer = sublist ? nullptr : _searchQueryFrom;
|
||||
const auto savedPeer = sublist
|
||||
? sublist->peer().get()
|
||||
: nullptr;
|
||||
_searchInHistoryRequest = histories.sendRequest(history, type, [=](Fn<void()> finish) {
|
||||
const auto type = _lastSearchId
|
||||
? SearchRequestType::PeerFromOffset
|
||||
@@ -2024,13 +2059,19 @@ void Widget::searchMore() {
|
||||
using Flag = MTPmessages_Search::Flag;
|
||||
_searchRequest = session().api().request(MTPmessages_Search(
|
||||
MTP_flags((topic ? Flag::f_top_msg_id : Flag())
|
||||
| (_searchQueryFrom ? Flag::f_from_id : Flag())),
|
||||
| (fromPeer ? Flag::f_from_id : Flag())
|
||||
| (savedPeer ? Flag::f_saved_peer_id : Flag())
|
||||
| (_searchQueryTags.empty()
|
||||
? Flag()
|
||||
: Flag::f_saved_reaction)),
|
||||
peer->input,
|
||||
MTP_string(_searchQuery),
|
||||
(_searchQueryFrom
|
||||
? _searchQueryFrom->input
|
||||
: MTP_inputPeerEmpty()),
|
||||
MTPInputPeer(), // saved_peer_id
|
||||
(fromPeer ? fromPeer->input : MTP_inputPeerEmpty()),
|
||||
(savedPeer ? savedPeer->input : MTP_inputPeerEmpty()),
|
||||
MTP_vector_from_range(
|
||||
_searchQueryTags | ranges::views::transform(
|
||||
Data::ReactionToMTP
|
||||
)),
|
||||
MTP_int(topic ? topic->rootId() : 0),
|
||||
MTP_inputMessagesFilterEmpty(),
|
||||
MTP_int(0), // min_date
|
||||
@@ -2104,6 +2145,7 @@ void Widget::searchMore() {
|
||||
? _searchQueryFrom->input
|
||||
: MTP_inputPeerEmpty()),
|
||||
MTPInputPeer(), // saved_peer_id
|
||||
MTPVector<MTPReaction>(), // saved_reaction
|
||||
MTPint(), // top_msg_id
|
||||
MTP_inputMessagesFilterEmpty(),
|
||||
MTP_int(0), // min_date
|
||||
@@ -2423,7 +2465,7 @@ void Widget::applyFilterUpdate(bool force) {
|
||||
updateStoriesVisibility();
|
||||
const auto filterText = currentSearchQuery();
|
||||
_inner->applyFilterUpdate(filterText, force);
|
||||
if (filterText.isEmpty() && !_searchFromAuthor) {
|
||||
if (filterText.isEmpty() && !_searchFromAuthor && _searchTags.empty()) {
|
||||
clearSearchCache();
|
||||
}
|
||||
_cancelSearch->toggle(!filterText.isEmpty(), anim::type::normal);
|
||||
@@ -2439,7 +2481,9 @@ void Widget::applyFilterUpdate(bool force) {
|
||||
_peerSearchQuery = QString();
|
||||
}
|
||||
|
||||
if (_chooseFromUser->toggled() || _searchFromAuthor) {
|
||||
if (_chooseFromUser->toggled()
|
||||
|| _searchFromAuthor
|
||||
|| !_searchTags.empty()) {
|
||||
auto switchToChooseFrom = HistoryView::SwitchToChooseFromQuery();
|
||||
if (_lastFilterText != switchToChooseFrom
|
||||
&& switchToChooseFrom.startsWith(_lastFilterText)
|
||||
@@ -2583,9 +2627,12 @@ void Widget::searchInChat(Key chat) {
|
||||
searchMessages(QString(), chat);
|
||||
}
|
||||
|
||||
bool Widget::setSearchInChat(Key chat, PeerData *from) {
|
||||
bool Widget::setSearchInChat(
|
||||
Key chat,
|
||||
PeerData *from,
|
||||
std::vector<Data::ReactionId> tags) {
|
||||
if (_childList) {
|
||||
if (_childList->setSearchInChat(chat, from)) {
|
||||
if (_childList->setSearchInChat(chat, from, tags)) {
|
||||
return true;
|
||||
}
|
||||
hideChildList();
|
||||
@@ -2621,7 +2668,8 @@ bool Widget::setSearchInChat(Key chat, PeerData *from) {
|
||||
if (_layout != Layout::Main) {
|
||||
return false;
|
||||
} else if (const auto migrateTo = peer->migrateTo()) {
|
||||
return setSearchInChat(peer->owner().history(migrateTo), from);
|
||||
const auto to = peer->owner().history(migrateTo);
|
||||
return setSearchInChat(to, from, tags);
|
||||
} else if (const auto migrateFrom = peer->migrateFrom()) {
|
||||
_searchInMigrated = peer->owner().history(migrateFrom);
|
||||
}
|
||||
@@ -2640,7 +2688,20 @@ bool Widget::setSearchInChat(Key chat, PeerData *from) {
|
||||
if (_searchInChat && _layout == Layout::Main) {
|
||||
controller()->closeFolder();
|
||||
}
|
||||
_inner->searchInChat(_searchInChat, _searchFromAuthor);
|
||||
_searchTags = std::move(tags);
|
||||
_inner->searchInChat(_searchInChat, _searchFromAuthor, _searchTags);
|
||||
_searchTagsLifetime = _inner->searchTagsValue(
|
||||
) | rpl::start_with_next([=](std::vector<Data::ReactionId> &&list) {
|
||||
if (_searchTags != list) {
|
||||
clearSearchCache();
|
||||
_searchTags = std::move(list);
|
||||
if (_searchTags.empty()) {
|
||||
applyFilterUpdate(true);
|
||||
} else {
|
||||
searchMessages();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (_subsectionTopBar) {
|
||||
_subsectionTopBar->searchEnableJumpToDate(
|
||||
_openedForum && _searchInChat);
|
||||
@@ -2653,6 +2714,12 @@ bool Widget::setSearchInChat(Key chat, PeerData *from) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Widget::setSearchInChat(
|
||||
Key chat,
|
||||
PeerData *from) {
|
||||
return setSearchInChat(chat, from, {});
|
||||
}
|
||||
|
||||
void Widget::clearSearchCache() {
|
||||
_searchCache.clear();
|
||||
_singleMessageSearch.clear();
|
||||
@@ -2661,6 +2728,7 @@ void Widget::clearSearchCache() {
|
||||
}
|
||||
_searchQuery = QString();
|
||||
_searchQueryFrom = nullptr;
|
||||
_searchQueryTags.clear();
|
||||
_topicSearchQuery = QString();
|
||||
_topicSearchOffsetDate = 0;
|
||||
_topicSearchOffsetId = _topicSearchOffsetTopicId = 0;
|
||||
@@ -3072,6 +3140,8 @@ void Widget::cancelSearchRequest() {
|
||||
PeerData *Widget::searchInPeer() const {
|
||||
return _openedForum
|
||||
? _openedForum->channel().get()
|
||||
: _searchInChat.sublist()
|
||||
? session().user().get()
|
||||
: _searchInChat.peer();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user