FdoNotifications: Only set the title of a Source once

Even though the comment in the code says that sources are reused even
thought the app title has changed this is actually not the case. Therefore
when ever the app title of a notification changes a new `Source` is
created. Therefore there is no point in setting the app title again.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3103>
This commit is contained in:
Julian Sparber 2024-01-25 21:11:50 +01:00 committed by Marge Bot
parent 00a375ce9b
commit c63d67c9af

View File

@ -101,10 +101,8 @@ class FdoNotificationDaemon {
return ndata.notification.source;
let source = this._lookupSource(title, pid);
if (source) {
source.setTitle(title);
if (source)
return source;
}
const appId = ndata?.hints['desktop-entry'];
source = new FdoNotificationDaemonSource(title, pid, sender, appId);
@ -312,10 +310,9 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
this.initialTitle = title;
this.app = this._getApp(appId);
super._init(title);
if (this.app)
this.title = this.app.get_name();
// Use app name as title if available, instead of whatever is provided
// through libnotify (usually garbage)
super._init(this.app ? this.app.get_name() : title);
if (sender) {
this._nameWatcherId = Gio.DBus.session.watch_name(sender,
@ -376,16 +373,6 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
return app;
}
setTitle(title) {
// Do nothing if .app is set, we don't want to override the
// app name with whatever is provided through libnotify (usually
// garbage)
if (this.app)
return;
super.setTitle(title);
}
open() {
this.openApp();
this.destroyNonResidentNotifications();