Display the number of unread messages in the notification icon

https://bugzilla.gnome.org/show_bug.cgi?id=654139
This commit is contained in:
Guillaume Desmottes 2011-06-27 14:31:53 +02:00
parent 6cb707cc4f
commit fda8ffd9ef

View File

@ -370,6 +370,8 @@ ChatSource.prototype = {
this._pendingMessages.push(message); this._pendingMessages.push(message);
} }
this._updateCount();
let showTimestamp = false; let showTimestamp = false;
for (let i = 0; i < logMessages.length; i++) { for (let i = 0; i < logMessages.length; i++) {
@ -414,11 +416,16 @@ ChatSource.prototype = {
this.destroy(); this.destroy();
}, },
_updateCount: function() {
this._setCount(this._pendingMessages.length, this._pendingMessages.length > 0);
},
_messageReceived: function(channel, message) { _messageReceived: function(channel, message) {
if (message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT) if (message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT)
return; return;
this._pendingMessages.push(message); this._pendingMessages.push(message);
this._updateCount();
message = makeMessageFromTpMessage(message, NotificationDirection.RECEIVED); message = makeMessageFromTpMessage(message, NotificationDirection.RECEIVED);
this._notification.appendMessage(message); this._notification.appendMessage(message);
@ -489,8 +496,10 @@ ChatSource.prototype = {
_pendingRemoved: function(channel, message) { _pendingRemoved: function(channel, message) {
let idx = this._pendingMessages.indexOf(message); let idx = this._pendingMessages.indexOf(message);
if (idx >= 0) if (idx >= 0) {
this._pendingMessages.splice(idx, 1); this._pendingMessages.splice(idx, 1);
this._updateCount();
}
else else
throw new Error('Message not in our pending list: ' + message); throw new Error('Message not in our pending list: ' + message);
}, },