mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-19 05:37:03 +00:00
Better check unique results in support mode.
This commit is contained in:
parent
5a388d9dde
commit
918d58ef0a
@ -404,7 +404,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_filterResults.isEmpty()) {
|
if (!_filterResults.empty()) {
|
||||||
auto skip = filteredOffset();
|
auto skip = filteredOffset();
|
||||||
auto from = floorclamp(r.y() - skip, st::dialogsRowHeight, 0, _filterResults.size());
|
auto from = floorclamp(r.y() - skip, st::dialogsRowHeight, 0, _filterResults.size());
|
||||||
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _filterResults.size());
|
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _filterResults.size());
|
||||||
@ -795,7 +795,7 @@ void DialogsInner::selectByMouse(QPoint globalPosition) {
|
|||||||
}
|
}
|
||||||
_hashtagDeleteSelected = (_hashtagSelected >= 0) && (local.x() >= w - st::mentionHeight);
|
_hashtagDeleteSelected = (_hashtagSelected >= 0) && (local.x() >= w - st::mentionHeight);
|
||||||
}
|
}
|
||||||
if (!_filterResults.isEmpty()) {
|
if (!_filterResults.empty()) {
|
||||||
auto skip = filteredOffset();
|
auto skip = filteredOffset();
|
||||||
auto filteredSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
auto filteredSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
||||||
if (filteredSelected < 0 || filteredSelected >= _filterResults.size()) {
|
if (filteredSelected < 0 || filteredSelected >= _filterResults.size()) {
|
||||||
@ -1367,7 +1367,7 @@ void DialogsInner::repaintDialogRow(
|
|||||||
}
|
}
|
||||||
} else if (_state == State::Filtered) {
|
} else if (_state == State::Filtered) {
|
||||||
if (list == Dialogs::Mode::All) {
|
if (list == Dialogs::Mode::All) {
|
||||||
for (auto i = 0, l = _filterResults.size(); i != l; ++i) {
|
for (auto i = 0, l = int(_filterResults.size()); i != l; ++i) {
|
||||||
if (_filterResults[i]->key() == row->key()) {
|
if (_filterResults[i]->key() == row->key()) {
|
||||||
update(
|
update(
|
||||||
0,
|
0,
|
||||||
@ -1439,7 +1439,7 @@ void DialogsInner::updateDialogRow(
|
|||||||
}
|
}
|
||||||
} else if (_state == State::Filtered) {
|
} else if (_state == State::Filtered) {
|
||||||
if ((sections & UpdateRowSection::Filtered)
|
if ((sections & UpdateRowSection::Filtered)
|
||||||
&& !_filterResults.isEmpty()) {
|
&& !_filterResults.empty()) {
|
||||||
const auto add = filteredOffset();
|
const auto add = filteredOffset();
|
||||||
auto index = 0;
|
auto index = 0;
|
||||||
for (const auto result : _filterResults) {
|
for (const auto result : _filterResults) {
|
||||||
@ -1503,7 +1503,7 @@ void DialogsInner::updateSelectedRow(Dialogs::Key key) {
|
|||||||
}
|
}
|
||||||
} else if (_state == State::Filtered) {
|
} else if (_state == State::Filtered) {
|
||||||
if (key) {
|
if (key) {
|
||||||
for (auto i = 0, l = _filterResults.size(); i != l; ++i) {
|
for (auto i = 0, l = int(_filterResults.size()); i != l; ++i) {
|
||||||
if (_filterResults[i]->key() == key) {
|
if (_filterResults[i]->key() == key) {
|
||||||
update(0, filteredOffset() + i * st::dialogsRowHeight, getFullWidth(), st::dialogsRowHeight);
|
update(0, filteredOffset() + i * st::dialogsRowHeight, getFullWidth(), st::dialogsRowHeight);
|
||||||
break;
|
break;
|
||||||
@ -1928,13 +1928,33 @@ bool DialogsInner::uniqueSearchResults() const {
|
|||||||
&& !_searchInChat;
|
&& !_searchInChat;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsInner::hasHistoryInSearchResults(not_null<History*> history) const {
|
bool DialogsInner::hasHistoryInResults(not_null<History*> history) const {
|
||||||
using Result = std::unique_ptr<Dialogs::FakeRow>;
|
using Result = std::unique_ptr<Dialogs::FakeRow>;
|
||||||
return ranges::find(
|
const auto inSearchResults = ranges::find(
|
||||||
_searchResults,
|
_searchResults,
|
||||||
history,
|
history,
|
||||||
[](const Result &result) { return result->item()->history(); }
|
[](const Result &result) { return result->item()->history(); }
|
||||||
) != end(_searchResults);
|
) != end(_searchResults);
|
||||||
|
if (inSearchResults) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const auto inFilteredResults = ranges::find(
|
||||||
|
_filterResults,
|
||||||
|
history.get(),
|
||||||
|
[](Dialogs::Row *row) { return row->history(); }
|
||||||
|
) != end(_filterResults);
|
||||||
|
if (inFilteredResults) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const auto inPeerSearchResults = ranges::find(
|
||||||
|
_peerSearchResults,
|
||||||
|
history->peer,
|
||||||
|
[](const auto &result) { return result->peer; }
|
||||||
|
) != end(_peerSearchResults);
|
||||||
|
if (inPeerSearchResults) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsInner::searchReceived(
|
bool DialogsInner::searchReceived(
|
||||||
@ -1959,7 +1979,7 @@ bool DialogsInner::searchReceived(
|
|||||||
message,
|
message,
|
||||||
NewMessageExisting);
|
NewMessageExisting);
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
if (!uniquePeers || !hasHistoryInSearchResults(history)) {
|
if (!uniquePeers || !hasHistoryInResults(history)) {
|
||||||
_searchResults.push_back(
|
_searchResults.push_back(
|
||||||
std::make_unique<Dialogs::FakeRow>(
|
std::make_unique<Dialogs::FakeRow>(
|
||||||
_searchInChat,
|
_searchInChat,
|
||||||
@ -2189,7 +2209,7 @@ DialogsInner::State DialogsInner::state() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsInner::hasFilteredResults() const {
|
bool DialogsInner::hasFilteredResults() const {
|
||||||
return !_filterResults.isEmpty() && _hashtagResults.empty();
|
return !_filterResults.empty() && _hashtagResults.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsInner::searchInChat(Dialogs::Key key, UserData *from) {
|
void DialogsInner::searchInChat(Dialogs::Key key, UserData *from) {
|
||||||
@ -2313,14 +2333,14 @@ void DialogsInner::selectSkip(int32 direction) {
|
|||||||
emit mustScrollTo(fromY, fromY + st::dialogsRowHeight);
|
emit mustScrollTo(fromY, fromY + st::dialogsRowHeight);
|
||||||
}
|
}
|
||||||
} else if (_state == State::Filtered) {
|
} else if (_state == State::Filtered) {
|
||||||
if (_hashtagResults.empty() && _filterResults.isEmpty() && _peerSearchResults.empty() && _searchResults.empty()) return;
|
if (_hashtagResults.empty() && _filterResults.empty() && _peerSearchResults.empty() && _searchResults.empty()) return;
|
||||||
if ((_hashtagSelected < 0 || _hashtagSelected >= _hashtagResults.size()) &&
|
if ((_hashtagSelected < 0 || _hashtagSelected >= _hashtagResults.size()) &&
|
||||||
(_filteredSelected < 0 || _filteredSelected >= _filterResults.size()) &&
|
(_filteredSelected < 0 || _filteredSelected >= _filterResults.size()) &&
|
||||||
(_peerSearchSelected < 0 || _peerSearchSelected >= _peerSearchResults.size()) &&
|
(_peerSearchSelected < 0 || _peerSearchSelected >= _peerSearchResults.size()) &&
|
||||||
(_searchedSelected < 0 || _searchedSelected >= _searchResults.size())) {
|
(_searchedSelected < 0 || _searchedSelected >= _searchResults.size())) {
|
||||||
if (_hashtagResults.empty() && _filterResults.isEmpty() && _peerSearchResults.empty()) {
|
if (_hashtagResults.empty() && _filterResults.empty() && _peerSearchResults.empty()) {
|
||||||
_searchedSelected = 0;
|
_searchedSelected = 0;
|
||||||
} else if (_hashtagResults.empty() && _filterResults.isEmpty()) {
|
} else if (_hashtagResults.empty() && _filterResults.empty()) {
|
||||||
_peerSearchSelected = 0;
|
_peerSearchSelected = 0;
|
||||||
} else if (_hashtagResults.empty()) {
|
} else if (_hashtagResults.empty()) {
|
||||||
_filteredSelected = 0;
|
_filteredSelected = 0;
|
||||||
@ -2377,7 +2397,7 @@ void DialogsInner::scrollToEntry(const Dialogs::RowDescriptor &entry) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fromY < 0) {
|
if (fromY < 0) {
|
||||||
for (auto i = 0, c = _filterResults.size(); i != c; ++i) {
|
for (auto i = 0, c = int(_filterResults.size()); i != c; ++i) {
|
||||||
if (_filterResults[i]->key() == entry.key) {
|
if (_filterResults[i]->key() == entry.key) {
|
||||||
fromY = filteredOffset() + (i * st::dialogsRowHeight);
|
fromY = filteredOffset() + (i * st::dialogsRowHeight);
|
||||||
break;
|
break;
|
||||||
@ -2658,7 +2678,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryBefore(
|
|||||||
}
|
}
|
||||||
if (isSearchResultActive(_searchResults[0].get(), which)) {
|
if (isSearchResultActive(_searchResults[0].get(), which)) {
|
||||||
if (_peerSearchResults.empty()) {
|
if (_peerSearchResults.empty()) {
|
||||||
if (_filterResults.isEmpty()) {
|
if (_filterResults.empty()) {
|
||||||
return Dialogs::RowDescriptor();
|
return Dialogs::RowDescriptor();
|
||||||
}
|
}
|
||||||
return Dialogs::RowDescriptor(
|
return Dialogs::RowDescriptor(
|
||||||
@ -2672,7 +2692,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryBefore(
|
|||||||
}
|
}
|
||||||
if (!_peerSearchResults.empty()
|
if (!_peerSearchResults.empty()
|
||||||
&& _peerSearchResults[0]->peer == whichHistory->peer) {
|
&& _peerSearchResults[0]->peer == whichHistory->peer) {
|
||||||
if (_filterResults.isEmpty()) {
|
if (_filterResults.empty()) {
|
||||||
return Dialogs::RowDescriptor();
|
return Dialogs::RowDescriptor();
|
||||||
}
|
}
|
||||||
return Dialogs::RowDescriptor(
|
return Dialogs::RowDescriptor(
|
||||||
@ -2688,7 +2708,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryBefore(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_filterResults.isEmpty() || _filterResults[0]->key() == which.key) {
|
if (_filterResults.empty() || _filterResults[0]->key() == which.key) {
|
||||||
return Dialogs::RowDescriptor();
|
return Dialogs::RowDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,13 +132,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct ImportantSwitch;
|
struct ImportantSwitch;
|
||||||
using DialogsList = std::unique_ptr<Dialogs::IndexedList>;
|
|
||||||
using FilteredDialogs = QVector<Dialogs::Row*>;
|
|
||||||
using SearchResults = std::vector<std::unique_ptr<Dialogs::FakeRow>>;
|
|
||||||
struct HashtagResult;
|
struct HashtagResult;
|
||||||
using HashtagResults = std::vector<std::unique_ptr<HashtagResult>>;
|
|
||||||
struct PeerSearchResult;
|
struct PeerSearchResult;
|
||||||
using PeerSearchResults = std::vector<std::unique_ptr<PeerSearchResult>>;
|
|
||||||
|
|
||||||
enum class JumpSkip {
|
enum class JumpSkip {
|
||||||
PreviousOrBegin,
|
PreviousOrBegin,
|
||||||
@ -190,7 +185,7 @@ private:
|
|||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const base::flat_set<QChar> &oldLetters);
|
const base::flat_set<QChar> &oldLetters);
|
||||||
bool uniqueSearchResults() const;
|
bool uniqueSearchResults() const;
|
||||||
bool hasHistoryInSearchResults(not_null<History*> history) const;
|
bool hasHistoryInResults(not_null<History*> history) const;
|
||||||
|
|
||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
Dialogs::RowDescriptor computeJump(
|
Dialogs::RowDescriptor computeJump(
|
||||||
@ -293,11 +288,11 @@ private:
|
|||||||
|
|
||||||
not_null<Window::Controller*> _controller;
|
not_null<Window::Controller*> _controller;
|
||||||
|
|
||||||
DialogsList _dialogs;
|
std::unique_ptr<Dialogs::IndexedList> _dialogs;
|
||||||
DialogsList _dialogsImportant;
|
std::unique_ptr<Dialogs::IndexedList> _dialogsImportant;
|
||||||
|
|
||||||
DialogsList _contactsNoDialogs;
|
std::unique_ptr<Dialogs::IndexedList> _contactsNoDialogs;
|
||||||
DialogsList _contacts;
|
std::unique_ptr<Dialogs::IndexedList> _contacts;
|
||||||
|
|
||||||
bool _mouseSelection = false;
|
bool _mouseSelection = false;
|
||||||
std::optional<QPoint> _lastMousePosition;
|
std::optional<QPoint> _lastMousePosition;
|
||||||
@ -328,13 +323,13 @@ private:
|
|||||||
int _visibleBottom = 0;
|
int _visibleBottom = 0;
|
||||||
QString _filter, _hashtagFilter;
|
QString _filter, _hashtagFilter;
|
||||||
|
|
||||||
HashtagResults _hashtagResults;
|
std::vector<std::unique_ptr<HashtagResult>> _hashtagResults;
|
||||||
int _hashtagSelected = -1;
|
int _hashtagSelected = -1;
|
||||||
int _hashtagPressed = -1;
|
int _hashtagPressed = -1;
|
||||||
bool _hashtagDeleteSelected = false;
|
bool _hashtagDeleteSelected = false;
|
||||||
bool _hashtagDeletePressed = false;
|
bool _hashtagDeletePressed = false;
|
||||||
|
|
||||||
FilteredDialogs _filterResults;
|
std::vector<Dialogs::Row*> _filterResults;
|
||||||
base::flat_map<
|
base::flat_map<
|
||||||
not_null<PeerData*>,
|
not_null<PeerData*>,
|
||||||
std::unique_ptr<Dialogs::Row>> _filterResultsGlobal;
|
std::unique_ptr<Dialogs::Row>> _filterResultsGlobal;
|
||||||
@ -344,11 +339,11 @@ private:
|
|||||||
bool _waitingForSearch = false;
|
bool _waitingForSearch = false;
|
||||||
|
|
||||||
QString _peerSearchQuery;
|
QString _peerSearchQuery;
|
||||||
PeerSearchResults _peerSearchResults;
|
std::vector<std::unique_ptr<PeerSearchResult>> _peerSearchResults;
|
||||||
int _peerSearchSelected = -1;
|
int _peerSearchSelected = -1;
|
||||||
int _peerSearchPressed = -1;
|
int _peerSearchPressed = -1;
|
||||||
|
|
||||||
SearchResults _searchResults;
|
std::vector<std::unique_ptr<Dialogs::FakeRow>> _searchResults;
|
||||||
int _searchedCount = 0;
|
int _searchedCount = 0;
|
||||||
int _searchedMigratedCount = 0;
|
int _searchedMigratedCount = 0;
|
||||||
int _searchedSelected = -1;
|
int _searchedSelected = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user