Left pane: small sorting fix, logging for error cases (#1969)
This commit is contained in:
parent
ce01eb7913
commit
743e897541
1 changed files with 38 additions and 16 deletions
|
@ -10,10 +10,33 @@
|
||||||
itemView: Whisper.ConversationListItemView,
|
itemView: Whisper.ConversationListItemView,
|
||||||
updateLocation: function(conversation) {
|
updateLocation: function(conversation) {
|
||||||
var $el = this.$('.' + conversation.cid);
|
var $el = this.$('.' + conversation.cid);
|
||||||
if ($el && $el.length > 0) {
|
|
||||||
|
if (!$el || !$el.length) {
|
||||||
|
console.log(
|
||||||
|
'updateLocation: did not find element for conversation',
|
||||||
|
conversation.idForLogging()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($el.length > 1) {
|
||||||
|
console.log(
|
||||||
|
'updateLocation: found more than one element for conversation',
|
||||||
|
conversation.idForLogging()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $allConversations = this.$('.conversation-list-item');
|
||||||
var inboxCollection = getInboxCollection();
|
var inboxCollection = getInboxCollection();
|
||||||
var index = inboxCollection.indexOf(conversation);
|
var index = inboxCollection.indexOf(conversation);
|
||||||
var elIndex = this.$el.index($el);
|
|
||||||
|
var elIndex = $allConversations.index($el);
|
||||||
|
if (elIndex < 0) {
|
||||||
|
console.log(
|
||||||
|
'updateLocation: did not find index for conversation',
|
||||||
|
conversation.idForLogging()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (index === elIndex) {
|
if (index === elIndex) {
|
||||||
return;
|
return;
|
||||||
|
@ -23,10 +46,9 @@
|
||||||
} else if (index === this.collection.length - 1) {
|
} else if (index === this.collection.length - 1) {
|
||||||
this.$el.append($el);
|
this.$el.append($el);
|
||||||
} else {
|
} else {
|
||||||
var targetConversation = inboxCollection.at(index + 1);
|
var targetConversation = inboxCollection.at(index - 1);
|
||||||
var target = this.$('.' + targetConversation.cid);
|
var target = this.$('.' + targetConversation.cid);
|
||||||
$el.insertBefore(target);
|
$el.insertAfter(target);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeItem: function(conversation) {
|
removeItem: function(conversation) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue