mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
Added ability to provide top msg id to api message search class.
This commit is contained in:
parent
d72c15e9d3
commit
0989a80a57
6 changed files with 26 additions and 2 deletions
|
@ -103,6 +103,7 @@ void MessagesSearch::searchRequest() {
|
|||
_requestId = _history->session().api().request(MTPmessages_Search(
|
||||
MTP_flags((fromPeer ? Flag::f_from_id : Flag())
|
||||
| (savedPeer ? Flag::f_saved_peer_id : Flag())
|
||||
| (_request.topMsgId ? Flag::f_top_msg_id : Flag())
|
||||
| (_request.tags.empty() ? Flag() : Flag::f_saved_reaction)),
|
||||
_history->peer->input,
|
||||
MTP_string(_request.query),
|
||||
|
@ -111,7 +112,7 @@ void MessagesSearch::searchRequest() {
|
|||
MTP_vector_from_range(_request.tags | ranges::views::transform(
|
||||
Data::ReactionToMTP
|
||||
)),
|
||||
MTPint(), // top_msg_id
|
||||
MTP_int(_request.topMsgId), // top_msg_id
|
||||
MTP_inputMessagesFilterEmpty(),
|
||||
MTP_int(0), // min_date
|
||||
MTP_int(0), // max_date
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
QString query;
|
||||
PeerData *from = nullptr;
|
||||
std::vector<Data::ReactionId> tags;
|
||||
MsgId topMsgId;
|
||||
|
||||
friend inline bool operator==(
|
||||
const Request &,
|
||||
|
|
|
@ -64,6 +64,10 @@ MessagesSearchMerged::MessagesSearchMerged(not_null<History*> history)
|
|||
}
|
||||
}
|
||||
|
||||
void MessagesSearchMerged::disableMigrated() {
|
||||
_migratedSearch = std::nullopt;
|
||||
}
|
||||
|
||||
void MessagesSearchMerged::addFound(const FoundMessages &data) {
|
||||
for (const auto &message : data.messages) {
|
||||
_concatedFound.messages.push_back(message);
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
void clear();
|
||||
void search(const Request &search);
|
||||
void searchMore();
|
||||
void disableMigrated();
|
||||
|
||||
[[nodiscard]] const FoundMessages &messages() const;
|
||||
[[nodiscard]] const Request &request() const;
|
||||
|
|
|
@ -840,6 +840,7 @@ public:
|
|||
void hideAnimated();
|
||||
void setInnerFocus();
|
||||
void setQuery(const QString &query);
|
||||
void setTopMsgId(MsgId topMsgId);
|
||||
|
||||
[[nodiscard]] rpl::producer<Activation> activations() const;
|
||||
[[nodiscard]] rpl::producer<> destroyRequests() const;
|
||||
|
@ -865,6 +866,8 @@ private:
|
|||
rpl::event_stream<BottomBar::Index> jumps;
|
||||
} _pendingJump;
|
||||
|
||||
MsgId _topMsgId;
|
||||
|
||||
rpl::event_stream<Activation> _activations;
|
||||
rpl::event_stream<> _destroyRequests;
|
||||
|
||||
|
@ -901,12 +904,13 @@ ComposeSearch::Inner::Inner(
|
|||
}, _topBar->lifetime());
|
||||
|
||||
_topBar->searchRequests(
|
||||
) | rpl::start_with_next([=](const SearchRequest &search) {
|
||||
) | rpl::start_with_next([=](SearchRequest search) {
|
||||
if (search.query.isEmpty() && search.tags.empty()) {
|
||||
if (!search.from || _history->peer->isSelf()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
search.topMsgId = _topMsgId;
|
||||
_apiSearch.clear();
|
||||
_apiSearch.search(search);
|
||||
}, _topBar->lifetime());
|
||||
|
@ -1045,6 +1049,13 @@ void ComposeSearch::Inner::setQuery(const QString &query) {
|
|||
_topBar->setQuery(query);
|
||||
}
|
||||
|
||||
void ComposeSearch::Inner::setTopMsgId(MsgId topMsgId) {
|
||||
if (topMsgId) {
|
||||
_apiSearch.disableMigrated();
|
||||
}
|
||||
_topMsgId = topMsgId;
|
||||
}
|
||||
|
||||
void ComposeSearch::Inner::showAnimated() {
|
||||
// Don't animate bottom bar.
|
||||
_bottomBar->show();
|
||||
|
@ -1103,6 +1114,10 @@ void ComposeSearch::setQuery(const QString &query) {
|
|||
_inner->setQuery(query);
|
||||
}
|
||||
|
||||
void ComposeSearch::setTopMsgId(MsgId topMsgId) {
|
||||
_inner->setTopMsgId(topMsgId);
|
||||
}
|
||||
|
||||
rpl::producer<ComposeSearch::Activation> ComposeSearch::activations() const {
|
||||
return _inner->activations();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ public:
|
|||
void setInnerFocus();
|
||||
void setQuery(const QString &query);
|
||||
|
||||
void setTopMsgId(MsgId topMsgId);
|
||||
|
||||
struct Activation {
|
||||
not_null<HistoryItem*> item;
|
||||
QString query;
|
||||
|
|
Loading…
Add table
Reference in a new issue