mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Highlight search query part in separate window chat.
This commit is contained in:
parent
13ea045055
commit
04023da723
6 changed files with 34 additions and 12 deletions
|
@ -74,12 +74,17 @@ const FoundMessages &MessagesSearchMerged::messages() const {
|
|||
return _concatedFound;
|
||||
}
|
||||
|
||||
const MessagesSearch::Request &MessagesSearchMerged::request() const {
|
||||
return _request;
|
||||
}
|
||||
|
||||
void MessagesSearchMerged::clear() {
|
||||
_concatedFound = {};
|
||||
_migratedFirstFound = {};
|
||||
}
|
||||
|
||||
void MessagesSearchMerged::search(const Request &search) {
|
||||
_request = search;
|
||||
if (_migratedSearch) {
|
||||
_waitingForTotal = true;
|
||||
_migratedSearch->searchMessages(search);
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
void searchMore();
|
||||
|
||||
[[nodiscard]] const FoundMessages &messages() const;
|
||||
[[nodiscard]] const Request &request() const;
|
||||
|
||||
[[nodiscard]] rpl::producer<> newFounds() const;
|
||||
[[nodiscard]] rpl::producer<> nextFounds() const;
|
||||
|
@ -39,6 +40,7 @@ private:
|
|||
void addFound(const FoundMessages &data);
|
||||
|
||||
MessagesSearch _apiSearch;
|
||||
Request _request;
|
||||
|
||||
std::optional<MessagesSearch> _migratedSearch;
|
||||
FoundMessages _migratedFirstFound;
|
||||
|
|
|
@ -5199,11 +5199,17 @@ void HistoryWidget::switchToSearch(QString query) {
|
|||
update();
|
||||
setInnerFocus();
|
||||
|
||||
using Activation = HistoryView::ComposeSearch::Activation;
|
||||
_composeSearch->activations(
|
||||
) | rpl::start_with_next([=](not_null<HistoryItem*> item) {
|
||||
) | rpl::start_with_next([=](Activation activation) {
|
||||
const auto item = activation.item;
|
||||
auto params = ::Window::SectionShow(
|
||||
::Window::SectionShow::Way::ClearStack);
|
||||
params.highlightPart = { activation.query };
|
||||
params.highlightPartOffsetHint = kSearchQueryOffsetHint;
|
||||
controller()->showPeerHistory(
|
||||
item->history()->peer->id,
|
||||
::Window::SectionShow::Way::ClearStack,
|
||||
params,
|
||||
item->fullId().msg);
|
||||
}, _composeSearch->lifetime());
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace HistoryView {
|
||||
namespace {
|
||||
|
||||
using Activation = ComposeSearch::Activation;
|
||||
using SearchRequest = Api::MessagesSearchMerged::Request;
|
||||
|
||||
[[nodiscard]] inline bool HasChooseFrom(not_null<History*> history) {
|
||||
|
@ -840,7 +841,7 @@ public:
|
|||
void setInnerFocus();
|
||||
void setQuery(const QString &query);
|
||||
|
||||
[[nodiscard]] rpl::producer<not_null<HistoryItem*>> activations() const;
|
||||
[[nodiscard]] rpl::producer<Activation> activations() const;
|
||||
[[nodiscard]] rpl::producer<> destroyRequests() const;
|
||||
[[nodiscard]] rpl::lifetime &lifetime();
|
||||
|
||||
|
@ -864,7 +865,7 @@ private:
|
|||
rpl::event_stream<BottomBar::Index> jumps;
|
||||
} _pendingJump;
|
||||
|
||||
rpl::event_stream<not_null<HistoryItem*>> _activations;
|
||||
rpl::event_stream<Activation> _activations;
|
||||
rpl::event_stream<> _destroyRequests;
|
||||
|
||||
};
|
||||
|
@ -966,7 +967,7 @@ ComposeSearch::Inner::Inner(
|
|||
const auto item = _history->owner().message(messages[index]);
|
||||
if (item) {
|
||||
const auto weak = Ui::MakeWeak(_topBar.get());
|
||||
_activations.fire_copy(item);
|
||||
_activations.fire_copy({ item, _apiSearch.request().query });
|
||||
if (weak) {
|
||||
hideList();
|
||||
}
|
||||
|
@ -1063,8 +1064,7 @@ void ComposeSearch::Inner::hideList() {
|
|||
}
|
||||
}
|
||||
|
||||
auto ComposeSearch::Inner::activations() const
|
||||
-> rpl::producer<not_null<HistoryItem*>> {
|
||||
rpl::producer<Activation> ComposeSearch::Inner::activations() const {
|
||||
return _activations.events();
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ void ComposeSearch::setQuery(const QString &query) {
|
|||
_inner->setQuery(query);
|
||||
}
|
||||
|
||||
rpl::producer<not_null<HistoryItem*>> ComposeSearch::activations() const {
|
||||
rpl::producer<ComposeSearch::Activation> ComposeSearch::activations() const {
|
||||
return _inner->activations();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,11 @@ public:
|
|||
void setInnerFocus();
|
||||
void setQuery(const QString &query);
|
||||
|
||||
[[nodiscard]] rpl::producer<not_null<HistoryItem*>> activations() const;
|
||||
struct Activation {
|
||||
not_null<HistoryItem*> item;
|
||||
QString query;
|
||||
};
|
||||
[[nodiscard]] rpl::producer<Activation> activations() const;
|
||||
[[nodiscard]] rpl::producer<> destroyRequests() const;
|
||||
|
||||
[[nodiscard]] rpl::lifetime &lifetime();
|
||||
|
|
|
@ -341,7 +341,7 @@ bool SublistWidget::searchInChatEmbedded(
|
|||
_composeSearch->setInnerFocus();
|
||||
return true;
|
||||
}
|
||||
_composeSearch = std::make_unique<HistoryView::ComposeSearch>(
|
||||
_composeSearch = std::make_unique<ComposeSearch>(
|
||||
this,
|
||||
controller(),
|
||||
_history,
|
||||
|
@ -352,10 +352,15 @@ bool SublistWidget::searchInChatEmbedded(
|
|||
setInnerFocus();
|
||||
|
||||
_composeSearch->activations(
|
||||
) | rpl::start_with_next([=](not_null<HistoryItem*> item) {
|
||||
) | rpl::start_with_next([=](ComposeSearch::Activation activation) {
|
||||
const auto item = activation.item;
|
||||
auto params = ::Window::SectionShow(
|
||||
::Window::SectionShow::Way::ClearStack);
|
||||
params.highlightPart = { activation.query };
|
||||
params.highlightPartOffsetHint = kSearchQueryOffsetHint;
|
||||
controller()->showPeerHistory(
|
||||
item->history()->peer->id,
|
||||
::Window::SectionShow::Way::ClearStack,
|
||||
params,
|
||||
item->fullId().msg);
|
||||
}, _composeSearch->lifetime());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue