0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-19 16:32:24 +01:00

SYWEB-28: Fixed weird members list ordering: sort members on their last activity absolute time

This commit is contained in:
Emmanuel ROHEE 2014-09-23 17:25:37 +02:00
parent c0673c50e6
commit e4e8ad6780

View file

@ -70,9 +70,16 @@ angular.module('matrixWebClient')
}); });
filtered.sort(function (a, b) { filtered.sort(function (a, b) {
// Sort members on their last_active_ago value // Sort members on their last_active absolute time
if (undefined !== a.last_active_ago || undefined !== b.last_active_ago) { var aLastActiveTS = 0, bLastActiveTS = 0;
return ((a.last_active_ago || 10e10) > (b.last_active_ago || 10e10) ? 1 : -1); if (undefined !== a.last_active_ago) {
aLastActiveTS = a.last_updated - a.last_active_ago;
}
if (undefined !== b.last_active_ago) {
bLastActiveTS = b.last_updated - b.last_active_ago;
}
if (aLastActiveTS || bLastActiveTS) {
return bLastActiveTS - aLastActiveTS;
} }
else { else {
// If they do not have last_active_ago, sort them according to their presence state // If they do not have last_active_ago, sort them according to their presence state