diff options
author | Ivan Sein <ivan@struktur.de> | 2018-03-29 09:58:28 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-04-19 17:31:29 +0300 |
commit | 68d5a1a237c2100e92ca8e10138720599d1dd0e6 (patch) | |
tree | 696e78e68c3a1e80bc2573d82344e662a0838b44 /js/models | |
parent | ecdc2cbfd3771be23905b2811318c90d7bdea3db (diff) |
Sort correctly room collection.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
Diffstat (limited to 'js/models')
-rw-r--r-- | js/models/roomcollection.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/js/models/roomcollection.js b/js/models/roomcollection.js index 65ba16b87..5f5580d50 100644 --- a/js/models/roomcollection.js +++ b/js/models/roomcollection.js @@ -28,8 +28,15 @@ var RoomCollection = Backbone.Collection.extend({ model: OCA.SpreedMe.Models.Room, - comparator: function(model) { - return [model.get('active') ? -1 : 0, -(model.get('lastPing'))]; + comparator: function(modelA, modelB) { + var activeA = modelA.get('active'), + activeB = modelB.get('active'); + + if (activeA !== activeB) { + return activeB - activeA; + } + + return modelA.get('lastPing') < modelB.get('lastPing');; }, url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'room', /** |