Clean up notification and unread indicator behavior

This commit is contained in:
lilia 2015-08-27 14:59:04 -07:00
parent e0f84d9c8e
commit 21aaf0fab5
3 changed files with 9 additions and 17 deletions

View file

@ -218,15 +218,9 @@
});
}
conversation.messageCollection.add(message);
conversation.save().then(function() {
message.save().then(function() {
updateInbox();
if (message.isIncoming()) {
notifyConversation(message);
} else {
updateConversation(conversation.id);
}
notifyConversation(message);
});
});
});

View file

@ -84,7 +84,6 @@
window.updateInbox = function() { // TODO: remove
ConversationController.updateInbox();
};
conversations.on('change:active_at', ConversationController.updateInbox);
ConversationController.updateInbox();
setUnreadCount(storage.get("unreadCount", 0));
@ -104,8 +103,7 @@
window.updateConversation = function(conversationId) {
var conversation = conversations.get(conversationId);
if (conversation) {
conversation.fetch();
conversation.fetchMessages();
conversation.reload();
}
};
@ -115,12 +113,11 @@
window.notifyConversation = function(message) {
var conversationId = message.get('conversationId');
var conversation = conversations.add({id: conversationId});
if (inboxOpened) {
// already open
updateConversation(conversationId);
conversation.reload();
extension.windows.drawAttention(inboxWindowId);
} else if (Whisper.Notifications.isEnabled()) {
var conversation = conversations.add({id: conversationId});
var sender = conversations.add({id: message.get('source')});
conversation.fetch().then(function() {
sender.fetch().then(function() {
@ -130,15 +127,14 @@
tag: conversation.id
});
notification.onclick = function() {
openConversation(conversation.id);
openInbox();
};
});
});
conversation.fetchMessages();
} else {
openConversation(conversationId);
openInbox();
extension.windows.drawAttention(windowId);
ConversationController.updateInbox();
}
};

View file

@ -66,7 +66,9 @@
appWindow: this.model.appWindow
});
$el = view.$el;
$el.find('.message-list').addClass('loading');
if (conversation.messageCollection.length === 0) {
$el.find('.message-list').addClass('loading');
}
}
$el.prependTo(this.el);
$el.find('.message-list').trigger('reset-scroll');