notification: Pass policy in the Source contructor
Commit 932ccac1
changed Source to use a regular constructor
instead of `_init()`.
Unfortunately that results in ordering issues for subclasses
that override `_createPolicy()`, if that method needs to access
any properties that are set in the constructor (as `this` is
only available after chaining up to the parent).
We can fix that by simply setting the policy from the constructor,
instead of relying on some overriden method being called.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3170>
This commit is contained in:

committed by
Marge Bot

parent
810391f41e
commit
3fc7ed4088
@ -307,13 +307,19 @@ class TelepathyClient extends Tp.BaseClient {
|
||||
|
||||
const ChatSource = HAVE_TP ? GObject.registerClass(
|
||||
class ChatSource extends MessageTray.Source {
|
||||
_init(account, conn, channel, contact, client) {
|
||||
constructor(account, conn, channel, contact, client) {
|
||||
const appId = account.protocol_name === 'irc'
|
||||
? 'org.gnome.Polari'
|
||||
: 'empathy';
|
||||
const policy =
|
||||
new MessageTray.NotificationApplicationPolicy(appId);
|
||||
|
||||
super({policy});
|
||||
|
||||
this._account = account;
|
||||
this._contact = contact;
|
||||
this._client = client;
|
||||
|
||||
super._init();
|
||||
|
||||
this._pendingMessages = [];
|
||||
|
||||
this._conn = conn;
|
||||
@ -356,12 +362,6 @@ class ChatSource extends MessageTray.Source {
|
||||
this.pushNotification(this._notification);
|
||||
}
|
||||
|
||||
_createPolicy() {
|
||||
if (this._account.protocol_name === 'irc')
|
||||
return new MessageTray.NotificationApplicationPolicy('org.gnome.Polari');
|
||||
return new MessageTray.NotificationApplicationPolicy('empathy');
|
||||
}
|
||||
|
||||
createBanner() {
|
||||
this._banner = new ChatNotificationBanner(this._notification);
|
||||
|
||||
|
Reference in New Issue
Block a user