2015-09-07 14:53:43 -07:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2015-01-18 14:16:24 -10:00
|
|
|
*/
|
2014-07-22 08:55:26 -10:00
|
|
|
(function () {
|
2015-03-05 15:44:53 -08:00
|
|
|
'use strict';
|
|
|
|
window.Whisper = window.Whisper || {};
|
2014-07-22 08:55:26 -10:00
|
|
|
|
2015-03-05 15:44:53 -08:00
|
|
|
Whisper.ConversationListView = Whisper.ListView.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
itemView: Whisper.ConversationListItemView,
|
2017-10-13 11:47:13 -07:00
|
|
|
updateLocation: function(conversation) {
|
2015-09-14 13:30:21 -07:00
|
|
|
var $el = this.$('.' + conversation.cid);
|
|
|
|
if ($el && $el.length > 0) {
|
2017-10-13 11:47:13 -07:00
|
|
|
var inboxCollection = getInboxCollection();
|
|
|
|
var index = inboxCollection.indexOf(conversation);
|
|
|
|
var elIndex = this.$el.index($el);
|
|
|
|
|
|
|
|
if (index === elIndex) {
|
2016-07-18 18:05:49 -07:00
|
|
|
return;
|
|
|
|
}
|
2016-03-27 15:29:53 -07:00
|
|
|
if (index === 0) {
|
2016-03-25 10:39:36 -07:00
|
|
|
this.$el.prepend($el);
|
2016-03-27 15:29:53 -07:00
|
|
|
} else if (index === this.collection.length - 1) {
|
|
|
|
this.$el.append($el);
|
|
|
|
} else {
|
2017-10-13 11:47:13 -07:00
|
|
|
var targetConversation = inboxCollection.at(index + 1);
|
|
|
|
var target = this.$('.' + targetConversation.cid);
|
|
|
|
$el.insertBefore(target);
|
2015-09-14 16:28:27 -07:00
|
|
|
}
|
2015-09-14 13:30:21 -07:00
|
|
|
}
|
2015-03-05 15:44:53 -08:00
|
|
|
}
|
|
|
|
});
|
2014-07-22 08:55:26 -10:00
|
|
|
})();
|