From dfd5df4265e90ad569c32c8370fb7ecff206af3e Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 9 Feb 2026 18:06:15 +0300 Subject: [PATCH] Removed unused search functions for calendar. --- .../data/data_search_controller.cpp | 74 ------------------- .../SourceFiles/data/data_search_controller.h | 18 ----- 2 files changed, 92 deletions(-) diff --git a/Telegram/SourceFiles/data/data_search_controller.cpp b/Telegram/SourceFiles/data/data_search_controller.cpp index f5cd92180c..2d01942c56 100644 --- a/Telegram/SourceFiles/data/data_search_controller.cpp +++ b/Telegram/SourceFiles/data/data_search_controller.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "data/data_search_controller.h" -#include "base/unixtime.h" #include "main/main_session.h" #include "data/data_session.h" #include "data/data_messages.h" @@ -335,79 +334,6 @@ HistoryResult ParseHistoryResult( data); } -std::optional PrepareSearchRequestByDate( - not_null peer, - MsgId topicRootId, - PeerId monoforumPeerId, - Storage::SharedMediaType type, - const QDate &date, - Data::LoadDirection direction) { - const auto filter = PrepareSearchFilter(type); - const auto minDate = base::unixtime::serialize( - QDateTime(date, QTime(0, 0))); - const auto maxDate = base::unixtime::serialize( - QDateTime(date.addDays(1), QTime(0, 0))) - 1; - const auto limit = kSharedMediaLimit; - const auto offsetId = 0; - const auto addOffset = 0; - const auto hash = uint64(0); - - using Flag = MTPmessages_Search::Flag; - return MTPmessages_Search( - MTP_flags((topicRootId ? Flag::f_top_msg_id : Flag(0)) - | (monoforumPeerId ? Flag::f_saved_peer_id : Flag(0))), - peer->input(), - MTP_string(""), - MTP_inputPeerEmpty(), - (monoforumPeerId - ? peer->owner().peer(monoforumPeerId)->input() - : MTPInputPeer()), - MTPVector(), - MTP_int(topicRootId), - filter, - MTP_int(minDate), - MTP_int(maxDate), - MTP_int(offsetId), - MTP_int(addOffset), - MTP_int(limit), - MTP_int(0), - MTP_int(0), - MTP_long(hash)); -} - -SearchResultByDate ParseSearchResultByDate( - not_null peer, - const QDate &date, - const SearchResult &parsed) { - const auto targetDate = base::unixtime::serialize( - QDateTime(date, QTime(0, 0))); - auto result = SearchResultByDate(); - if (parsed.messageIds.empty()) { - return result; - } - const auto firstMsgId = parsed.messageIds.front(); - result.first = Data::MessagePosition{ - .fullId = FullMsgId(peer->id, firstMsgId), - .date = TimeId(0), - }; - auto closestMsgId = firstMsgId; - auto minDiff = std::numeric_limits::max(); - for (const auto msgId : parsed.messageIds) { - if (const auto item = peer->owner().message(peer->id, msgId)) { - const auto diff = std::abs(item->date() - targetDate); - if (diff < minDiff) { - minDiff = diff; - closestMsgId = msgId; - } - } - } - result.closestToDate = Data::MessagePosition{ - .fullId = FullMsgId(peer->id, closestMsgId), - .date = TimeId(0), - }; - return result; -} - SearchController::CacheEntry::CacheEntry( not_null session, const Query &query) diff --git a/Telegram/SourceFiles/data/data_search_controller.h b/Telegram/SourceFiles/data/data_search_controller.h index a4d5690360..e7fb3f8e9f 100644 --- a/Telegram/SourceFiles/data/data_search_controller.h +++ b/Telegram/SourceFiles/data/data_search_controller.h @@ -44,11 +44,6 @@ struct GlobalMediaResult { int fullCount = 0; }; -struct SearchResultByDate { - Data::MessagePosition first; - Data::MessagePosition closestToDate; -}; - [[nodiscard]] MTPMessagesFilter PrepareSearchFilter( Storage::SharedMediaType type); @@ -79,19 +74,6 @@ struct SearchResultByDate { Data::LoadDirection direction, const SearchRequestResult &data); -[[nodiscard]] std::optional PrepareSearchRequestByDate( - not_null peer, - MsgId topicRootId, - PeerId monoforumPeerId, - Storage::SharedMediaType type, - const QDate &date, - Data::LoadDirection direction); - -[[nodiscard]] SearchResultByDate ParseSearchResultByDate( - not_null peer, - const QDate &date, - const SearchResult &parsed); - [[nodiscard]] HistoryRequest PrepareHistoryRequest( not_null peer, MsgId messageId,