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:
@@ -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);
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user