Fixes #61 - Order by timestamps with tests

This commit is contained in:
Arnaud Benard 2014-10-18 15:08:57 +01:00 committed by lilia
parent cc5327dbc9
commit e568e2c528
4 changed files with 31 additions and 3 deletions

View file

@ -61,7 +61,11 @@ var Whisper = Whisper || {};
Whisper.Threads = new (Backbone.Collection.extend({
localStorage: new Backbone.LocalStorage("Threads"),
model: Thread,
comparator: 'timestamp',
comparator: function(m) {
return -m.get('timestamp');
},
findOrCreate: function(attributes) {
var thread = Whisper.Threads.add(attributes, {merge: true});
thread.save();
@ -112,5 +116,6 @@ var Whisper = Whisper || {};
}
return this.findOrCreate(attributes);
}
}))();
})();