mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Fix switching between hashtag results.
This commit is contained in:
parent
bf9069524a
commit
90c1c21646
2 changed files with 31 additions and 20 deletions
|
@ -477,15 +477,9 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO
|
||||||
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _searchResults.size());
|
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _searchResults.size());
|
||||||
p.translate(0, from * st::dialogsRowHeight);
|
p.translate(0, from * st::dialogsRowHeight);
|
||||||
if (from < _searchResults.size()) {
|
if (from < _searchResults.size()) {
|
||||||
const auto activePeer = activeEntry.key.peer();
|
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
const auto &result = _searchResults[from];
|
const auto &result = _searchResults[from];
|
||||||
const auto item = result->item();
|
const auto active = isSearchResultActive(result.get(), activeEntry);
|
||||||
const auto peer = item->history()->peer;
|
|
||||||
const auto active = (item->fullId() == activeEntry.fullId)
|
|
||||||
|| (peer->migrateTo()
|
|
||||||
&& (peer->migrateTo()->bareId() == activeEntry.fullId.channel)
|
|
||||||
&& (item->id == -activeEntry.fullId.msg));
|
|
||||||
const auto selected = (from == (isPressed()
|
const auto selected = (from == (isPressed()
|
||||||
? _searchedPressed
|
? _searchedPressed
|
||||||
: _searchedSelected));
|
: _searchedSelected));
|
||||||
|
@ -505,6 +499,18 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DialogsInner::isSearchResultActive(
|
||||||
|
not_null<Dialogs::FakeRow*> result,
|
||||||
|
const Dialogs::RowDescriptor &entry) const {
|
||||||
|
const auto item = result->item();
|
||||||
|
const auto peer = item->history()->peer;
|
||||||
|
return (item->fullId() == entry.fullId)
|
||||||
|
|| (peer->migrateTo()
|
||||||
|
&& (peer->migrateTo()->bareId() == entry.fullId.channel)
|
||||||
|
&& (item->id == -entry.fullId.msg))
|
||||||
|
|| (uniqueSearchResults() && peer == entry.key.peer());
|
||||||
|
}
|
||||||
|
|
||||||
void DialogsInner::paintPeerSearchResult(
|
void DialogsInner::paintPeerSearchResult(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
not_null<const PeerSearchResult*> result,
|
not_null<const PeerSearchResult*> result,
|
||||||
|
@ -2576,16 +2582,16 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryBefore(
|
||||||
if (!whichHistory) {
|
if (!whichHistory) {
|
||||||
return Dialogs::RowDescriptor();
|
return Dialogs::RowDescriptor();
|
||||||
}
|
}
|
||||||
if (whichFullId && !_searchResults.empty()) {
|
if (!_searchResults.empty()) {
|
||||||
for (auto b = _searchResults.cbegin(), i = b + 1, e = _searchResults.cend(); i != e; ++i) {
|
for (auto b = _searchResults.cbegin(), i = b + 1, e = _searchResults.cend(); i != e; ++i) {
|
||||||
if ((*i)->item()->fullId() == whichFullId) {
|
if (isSearchResultActive(i->get(), which)) {
|
||||||
const auto j = i - 1;
|
const auto j = i - 1;
|
||||||
return Dialogs::RowDescriptor(
|
return Dialogs::RowDescriptor(
|
||||||
(*j)->item()->history(),
|
(*j)->item()->history(),
|
||||||
(*j)->item()->fullId());
|
(*j)->item()->fullId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_searchResults[0]->item()->fullId() == whichFullId) {
|
if (isSearchResultActive(_searchResults[0].get(), which)) {
|
||||||
if (_peerSearchResults.empty()) {
|
if (_peerSearchResults.empty()) {
|
||||||
if (_filterResults.isEmpty()) {
|
if (_filterResults.isEmpty()) {
|
||||||
return Dialogs::RowDescriptor();
|
return Dialogs::RowDescriptor();
|
||||||
|
@ -2653,16 +2659,14 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryAfter(
|
||||||
if (!whichHistory) {
|
if (!whichHistory) {
|
||||||
return Dialogs::RowDescriptor();
|
return Dialogs::RowDescriptor();
|
||||||
}
|
}
|
||||||
if (whichFullId) {
|
for (auto i = _searchResults.cbegin(), e = _searchResults.cend(); i != e; ++i) {
|
||||||
for (auto i = _searchResults.cbegin(), e = _searchResults.cend(); i != e; ++i) {
|
if (isSearchResultActive(i->get(), which)) {
|
||||||
if ((*i)->item()->fullId() == whichFullId) {
|
if (++i != e) {
|
||||||
if (++i != e) {
|
return Dialogs::RowDescriptor(
|
||||||
return Dialogs::RowDescriptor(
|
(*i)->item()->history(),
|
||||||
(*i)->item()->history(),
|
(*i)->item()->fullId());
|
||||||
(*i)->item()->fullId());
|
|
||||||
}
|
|
||||||
return Dialogs::RowDescriptor();
|
|
||||||
}
|
}
|
||||||
|
return Dialogs::RowDescriptor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto i = _peerSearchResults.cbegin(), e = _peerSearchResults.cend(); i != e; ++i) {
|
for (auto i = _peerSearchResults.cbegin(), e = _peerSearchResults.cend(); i != e; ++i) {
|
||||||
|
@ -2836,7 +2840,11 @@ Dialogs::RowDescriptor DialogsInner::computeJump(
|
||||||
|
|
||||||
bool DialogsInner::jumpToDialogRow(const Dialogs::RowDescriptor &to) {
|
bool DialogsInner::jumpToDialogRow(const Dialogs::RowDescriptor &to) {
|
||||||
if (const auto history = to.key.history()) {
|
if (const auto history = to.key.history()) {
|
||||||
Ui::showPeerHistory(history, to.fullId.msg);
|
Ui::showPeerHistory(
|
||||||
|
history,
|
||||||
|
(uniqueSearchResults()
|
||||||
|
? ShowAtUnreadMsgId
|
||||||
|
: to.fullId.msg));
|
||||||
return true;
|
return true;
|
||||||
} else if (const auto feed = to.key.feed()) {
|
} else if (const auto feed = to.key.feed()) {
|
||||||
if (const auto item = App::histItemById(to.fullId)) {
|
if (const auto item = App::histItemById(to.fullId)) {
|
||||||
|
|
|
@ -150,6 +150,9 @@ private:
|
||||||
bool switchImportantChats();
|
bool switchImportantChats();
|
||||||
bool chooseHashtag();
|
bool chooseHashtag();
|
||||||
ChosenRow computeChosenRow() const;
|
ChosenRow computeChosenRow() const;
|
||||||
|
bool isSearchResultActive(
|
||||||
|
not_null<Dialogs::FakeRow*> result,
|
||||||
|
const Dialogs::RowDescriptor &entry) const;
|
||||||
|
|
||||||
void userIsContactUpdated(not_null<UserData*> user);
|
void userIsContactUpdated(not_null<UserData*> user);
|
||||||
void mousePressReleased(Qt::MouseButton button);
|
void mousePressReleased(Qt::MouseButton button);
|
||||||
|
|
Loading…
Add table
Reference in a new issue