[gnome-shell/wip/fmuellner/es6-class-preparations: 4/5] messageTray: Split out policy creation
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/fmuellner/es6-class-preparations: 4/5] messageTray: Split out policy creation
- Date: Tue, 15 Jan 2019 17:51:09 +0000 (UTC)
commit 4c3b4422c187106e88e2e6b346a860c1b1451538
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Nov 1 19:21:31 2017 +0100
messageTray: Split out policy creation
The _createPolicy() method of a subclass usually depends on some
constructor parameters that need to be set before chaining up to
the parent. This works fine with Lang.Class, but will break with
ES6 classes, as "this" is only initialized after chaining up.
Prepare for this by not creating the policy in the constructor,
but when it is first accessed.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/350
js/ui/messageTray.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index fc4e00c9d..7ce977f47 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -701,7 +701,13 @@ var Source = new Lang.Class({
this.notifications = [];
- this.policy = this._createPolicy();
+ this._policy = null;
+ },
+
+ get policy() {
+ if (!this._policy)
+ this._policy = this._createPolicy();
+ return this._policy;
},
get count() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]