void ChatSearchFromController::rebuildRows() { auto ms = getms(); auto wasEmpty = !delegate()->peerListFullRowsCount(); auto now = unixtime(); QMultiMap<int32, UserData*> ordered; if (_chat->noParticipantInfo()) { AuthSession::Current().api().requestFullPeer(_chat); } else if (!_chat->participants.isEmpty()) { for (auto i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) { auto user = i.key(); ordered.insertMulti(App::onlineForSort(user, now), user); } } for_const (auto user, _chat->lastAuthors) { if (user->isInaccessible()) continue; appendRow(user); if (!ordered.isEmpty()) { ordered.remove(App::onlineForSort(user, now), user); } } if (!ordered.isEmpty()) { for (auto i = ordered.cend(), b = ordered.cbegin(); i != b;) { appendRow(*(--i)); } } checkForEmptyRows(); delegate()->peerListRefreshRows(); }