Commit d825a15b authored by JC Brand's avatar JC Brand

Clear when maximizing a chat box

parent f3d29e01
......@@ -933,6 +933,21 @@
/* -------- Event Handlers ----------- */
var onChatBoxMaximized = function (chatboxview) {
/* When a chat box gets maximized, the num_unread counter needs
* to be cleared.
*/
var chatbox = chatboxview.model;
if (chatbox.get('type') === 'chatroom') {
// TODO
} else {
var contact = _.head(_converse.roster.where({'jid': chatbox.get('jid')}));
if (!_.isUndefined(contact)) {
contact.save({'num_unread': 0});
}
}
};
var onMessageReceived = function (data) {
/* Given a newly received message, update the unread counter on
* the relevant roster contact (TODO: or chat room).
......@@ -971,6 +986,7 @@
_converse.api.listen.on('rosterInitialized', initRoster);
_converse.api.listen.on('rosterReadyAfterReconnection', initRoster);
_converse.api.listen.on('message', onMessageReceived);
_converse.api.listen.on('chatBoxMaximized', onChatBoxMaximized);
}
});
}));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment