mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-01 15:15:13 +00:00
Add archived results in chats search.
This commit is contained in:
@@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_folder.h"
|
||||
#include "auth_session.h"
|
||||
#include "core/application.h"
|
||||
#include "styles/style_boxes.h"
|
||||
@@ -131,7 +132,7 @@ private:
|
||||
ShareBox::FilterCallback _filterCallback;
|
||||
std::unique_ptr<Dialogs::IndexedList> _chatsIndexed;
|
||||
QString _filter;
|
||||
std::vector<Dialogs::Row*> _filtered;
|
||||
std::vector<not_null<Dialogs::Row*>> _filtered;
|
||||
|
||||
std::map<not_null<PeerData*>, std::unique_ptr<Chat>> _dataMap;
|
||||
base::flat_set<not_null<PeerData*>> _selected;
|
||||
@@ -489,19 +490,26 @@ ShareBox::Inner::Inner(
|
||||
_rowHeight = st::shareRowHeight;
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
||||
const auto dialogs = Auth().data().chatsList()->indexed();
|
||||
const auto self = Auth().user();
|
||||
if (_filterCallback(self)) {
|
||||
_chatsIndexed->addToEnd(self->owner().history(self));
|
||||
}
|
||||
for (const auto row : dialogs->all()) {
|
||||
if (const auto history = row->history()) {
|
||||
if (!history->peer->isSelf()
|
||||
&& _filterCallback(history->peer)) {
|
||||
_chatsIndexed->addToEnd(history);
|
||||
const auto addList = [&](not_null<Dialogs::IndexedList*> list) {
|
||||
for (const auto row : list->all()) {
|
||||
if (const auto history = row->history()) {
|
||||
if (!history->peer->isSelf()
|
||||
&& _filterCallback(history->peer)) {
|
||||
_chatsIndexed->addToEnd(history);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
addList(Auth().data().chatsList()->indexed());
|
||||
const auto id = Data::Folder::kId;
|
||||
if (const auto folder = Auth().data().folderLoaded(id)) {
|
||||
addList(folder->chatsList()->indexed());
|
||||
}
|
||||
addList(Auth().data().contactsNoChatsList());
|
||||
|
||||
_filter = qsl("a");
|
||||
updateFilter();
|
||||
@@ -603,7 +611,7 @@ ShareBox::Inner::Chat *ShareBox::Inner::getChatAtIndex(int index) {
|
||||
return _chatsIndexed->rowAtY(index, 1);
|
||||
}
|
||||
return (index < _filtered.size())
|
||||
? _filtered[index]
|
||||
? _filtered[index].get()
|
||||
: nullptr;
|
||||
}();
|
||||
if (row) {
|
||||
@@ -944,45 +952,7 @@ void ShareBox::Inner::updateFilter(QString filter) {
|
||||
if (_filter.isEmpty()) {
|
||||
refresh();
|
||||
} else {
|
||||
QStringList::const_iterator fb = words.cbegin(), fe = words.cend(), fi;
|
||||
|
||||
_filtered.clear();
|
||||
if (!words.isEmpty()) {
|
||||
const Dialogs::List *toFilter = nullptr;
|
||||
if (!_chatsIndexed->empty()) {
|
||||
for (fi = fb; fi != fe; ++fi) {
|
||||
const auto found = _chatsIndexed->filtered(fi->at(0));
|
||||
if (!found || found->empty()) {
|
||||
toFilter = nullptr;
|
||||
break;
|
||||
}
|
||||
if (!toFilter || toFilter->size() > found->size()) {
|
||||
toFilter = found;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toFilter) {
|
||||
_filtered.reserve(toFilter->size());
|
||||
for (const auto row : *toFilter) {
|
||||
const auto &nameWords = row->entry()->chatListNameWords();
|
||||
auto nb = nameWords.cbegin(), ne = nameWords.cend(), ni = nb;
|
||||
for (fi = fb; fi != fe; ++fi) {
|
||||
auto filterName = *fi;
|
||||
for (ni = nb; ni != ne; ++ni) {
|
||||
if (ni->startsWith(*fi)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ni == ne) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fi == fe) {
|
||||
_filtered.push_back(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_filtered = _chatsIndexed->filtered(words);
|
||||
refresh();
|
||||
|
||||
_searching = true;
|
||||
|
Reference in New Issue
Block a user