messageTray: Clean up code that determines if something is clearable
https://bugzilla.gnome.org/show_bug.cgi?id=710115
This commit is contained in:
parent
4cda61a16a
commit
da14e2c349
@ -1211,6 +1211,10 @@ const Source = new Lang.Class({
|
|||||||
return this.count > 1;
|
return this.count > 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get isClearable() {
|
||||||
|
return !this.trayIcon && !this.isChat && !this.resident;
|
||||||
|
},
|
||||||
|
|
||||||
countUpdated: function() {
|
countUpdated: function() {
|
||||||
this.emit('count-updated');
|
this.emit('count-updated');
|
||||||
},
|
},
|
||||||
@ -1540,22 +1544,14 @@ const MessageTrayMenu = new Lang.Class({
|
|||||||
this.addMenuItem(separator);
|
this.addMenuItem(separator);
|
||||||
|
|
||||||
this._clearItem = this.addAction(_("Clear Messages"), function() {
|
this._clearItem = this.addAction(_("Clear Messages"), function() {
|
||||||
let toDestroy = [];
|
let toDestroy = tray.getSources().filter(function(source) {
|
||||||
let sources = tray.getSources();
|
return source.isClearable;
|
||||||
for (let i = 0; i < sources.length; i++) {
|
})
|
||||||
// We exclude trayIcons, chat and resident sources
|
|
||||||
if (sources[i].trayIcon ||
|
|
||||||
sources[i].isChat ||
|
|
||||||
sources[i].resident)
|
|
||||||
continue;
|
|
||||||
toDestroy.push(sources[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < toDestroy.length; i++) {
|
toDestroy.forEach(function(source) {
|
||||||
toDestroy[i].destroy();
|
source.destroy();
|
||||||
}
|
});
|
||||||
|
|
||||||
toDestroy = null;
|
|
||||||
tray.close();
|
tray.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1989,7 +1985,7 @@ const MessageTray = new Lang.Class({
|
|||||||
this._summary.insert_child_at_index(summaryItem.actor, this._chatSummaryItemsCount);
|
this._summary.insert_child_at_index(summaryItem.actor, this._chatSummaryItemsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!source.trayIcon && !source.isChat && !source.resident)
|
if (source.isClearable)
|
||||||
this.clearableCount++;
|
this.clearableCount++;
|
||||||
|
|
||||||
this._sources.set(source, obj);
|
this._sources.set(source, obj);
|
||||||
@ -2033,7 +2029,7 @@ const MessageTray = new Lang.Class({
|
|||||||
if (source.isChat)
|
if (source.isChat)
|
||||||
this._chatSummaryItemsCount--;
|
this._chatSummaryItemsCount--;
|
||||||
|
|
||||||
if (!source.trayIcon && !source.isChat && !source.resident)
|
if (source.isClearable)
|
||||||
this.clearableCount--;
|
this.clearableCount--;
|
||||||
|
|
||||||
source.disconnect(obj.notifyId);
|
source.disconnect(obj.notifyId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user