Clean up notification and unread indicator behavior
This commit is contained in:
parent
e0f84d9c8e
commit
21aaf0fab5
3 changed files with 9 additions and 17 deletions
|
@ -218,15 +218,9 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
conversation.messageCollection.add(message);
|
|
||||||
conversation.save().then(function() {
|
conversation.save().then(function() {
|
||||||
message.save().then(function() {
|
message.save().then(function() {
|
||||||
updateInbox();
|
|
||||||
if (message.isIncoming()) {
|
|
||||||
notifyConversation(message);
|
notifyConversation(message);
|
||||||
} else {
|
|
||||||
updateConversation(conversation.id);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -84,7 +84,6 @@
|
||||||
window.updateInbox = function() { // TODO: remove
|
window.updateInbox = function() { // TODO: remove
|
||||||
ConversationController.updateInbox();
|
ConversationController.updateInbox();
|
||||||
};
|
};
|
||||||
conversations.on('change:active_at', ConversationController.updateInbox);
|
|
||||||
|
|
||||||
ConversationController.updateInbox();
|
ConversationController.updateInbox();
|
||||||
setUnreadCount(storage.get("unreadCount", 0));
|
setUnreadCount(storage.get("unreadCount", 0));
|
||||||
|
@ -104,8 +103,7 @@
|
||||||
window.updateConversation = function(conversationId) {
|
window.updateConversation = function(conversationId) {
|
||||||
var conversation = conversations.get(conversationId);
|
var conversation = conversations.get(conversationId);
|
||||||
if (conversation) {
|
if (conversation) {
|
||||||
conversation.fetch();
|
conversation.reload();
|
||||||
conversation.fetchMessages();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,12 +113,11 @@
|
||||||
|
|
||||||
window.notifyConversation = function(message) {
|
window.notifyConversation = function(message) {
|
||||||
var conversationId = message.get('conversationId');
|
var conversationId = message.get('conversationId');
|
||||||
|
var conversation = conversations.add({id: conversationId});
|
||||||
if (inboxOpened) {
|
if (inboxOpened) {
|
||||||
// already open
|
conversation.reload();
|
||||||
updateConversation(conversationId);
|
|
||||||
extension.windows.drawAttention(inboxWindowId);
|
extension.windows.drawAttention(inboxWindowId);
|
||||||
} else if (Whisper.Notifications.isEnabled()) {
|
} else if (Whisper.Notifications.isEnabled()) {
|
||||||
var conversation = conversations.add({id: conversationId});
|
|
||||||
var sender = conversations.add({id: message.get('source')});
|
var sender = conversations.add({id: message.get('source')});
|
||||||
conversation.fetch().then(function() {
|
conversation.fetch().then(function() {
|
||||||
sender.fetch().then(function() {
|
sender.fetch().then(function() {
|
||||||
|
@ -130,15 +127,14 @@
|
||||||
tag: conversation.id
|
tag: conversation.id
|
||||||
});
|
});
|
||||||
notification.onclick = function() {
|
notification.onclick = function() {
|
||||||
openConversation(conversation.id);
|
openInbox();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
conversation.fetchMessages();
|
conversation.fetchMessages();
|
||||||
} else {
|
} else {
|
||||||
openConversation(conversationId);
|
|
||||||
openInbox();
|
openInbox();
|
||||||
extension.windows.drawAttention(windowId);
|
ConversationController.updateInbox();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,10 @@
|
||||||
appWindow: this.model.appWindow
|
appWindow: this.model.appWindow
|
||||||
});
|
});
|
||||||
$el = view.$el;
|
$el = view.$el;
|
||||||
|
if (conversation.messageCollection.length === 0) {
|
||||||
$el.find('.message-list').addClass('loading');
|
$el.find('.message-list').addClass('loading');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$el.prependTo(this.el);
|
$el.prependTo(this.el);
|
||||||
$el.find('.message-list').trigger('reset-scroll');
|
$el.find('.message-list').trigger('reset-scroll');
|
||||||
$el.trigger('force-resize');
|
$el.trigger('force-resize');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue