2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-10-07 13:26:47 +00:00

Improve sorting by online in info profile.

This commit is contained in:
John Preston
2017-09-26 21:44:58 +03:00
parent 292e57ffc7
commit 2c75b4836d
4 changed files with 63 additions and 4 deletions

View File

@@ -61,11 +61,20 @@ void ChatMembersController::prepare() {
if (!delegate()->peerListFullRowsCount()) {
Auth().api().requestFullPeer(_chat);
}
using UpdateFlag = Notify::PeerUpdate::Flag;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(
Notify::PeerUpdate::Flag::MembersChanged,
UpdateFlag::MembersChanged | UpdateFlag::UserOnlineChanged,
[this](const Notify::PeerUpdate &update) {
if (update.peer == _chat) {
rebuildRows();
if (update.flags & UpdateFlag::MembersChanged) {
if (update.peer == _chat) {
rebuildRows();
}
} else if (update.flags & UpdateFlag::UserOnlineChanged) {
auto now = unixtime();
delegate()->peerListSortRows([now](const PeerListRow &a, const PeerListRow &b) {
return App::onlineForSort(a.peer()->asUser(), now) >
App::onlineForSort(b.peer()->asUser(), now);
});
}
}));
}