[gnome-shell/wip/fmuellner/policy-setter] messageTray: Add source policy setter



commit 9a73584f4358d876af63f376e88f4e218cf692d1
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Mar 2 20:53:33 2019 +0100

    messageTray: Add source policy setter
    
    Commit 8f15193b4 changed the `policy` property from a regular JS property to
    a getter. This was necessary to avoid calling an overridden _createPolicy()
    method before a subclass is properly initialized, but it broke the second
    way of using notification sources:
    
    Don't create a Source subclass, but use the base class directly and change
    its `policy` property.
    
    There's no good reason why we should no longer allow this, so add a setter.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/431

 js/ui/messageTray.js | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index dcba4788f..8f8130451 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -708,6 +708,12 @@ var Source = class Source {
         return this._policy;
     }
 
+    set policy(policy) {
+        if (this._policy)
+            this._policy.destroy();
+        this._policy = policy;
+    }
+
     get count() {
         return this.notifications.length;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]