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