summarylogtreecommitdiffstats
path: root/1126.diff
blob: c7f0199bd93f5993fc8bfe6e9bf812f3e4b33ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 99641841768fca6ef96bb41197fce1c75040fbc2..286aac1e10ee9bd966a98a86eb10cb7210ff3ff6 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -199,46 +199,47 @@ class DBusEventSource extends EventSourceBase {
 
         this._initialized = false;
         this._dbusProxy = new CalendarServer();
-        this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, (object, result) => {
-            let loaded = false;
-
-            try {
-                this._dbusProxy.init_finish(result);
-                loaded = true;
-            } catch (e) {
-                if (e.matches(Gio.DBusError, Gio.DBusError.TIMED_OUT)) {
-                    // Ignore timeouts and install signals as normal, because with high
-                    // probability the service will appear later on, and we will get a
-                    // NameOwnerChanged which will finish loading
-                    //
-                    // (But still _initialized to false, because the proxy does not know
-                    // about the HasCalendars property and would cause an exception trying
-                    // to read it)
-                } else {
-                    log('Error loading calendars: %s'.format(e.message));
-                    return;
-                }
+        this._initProxy();
+    }
+
+    async _initProxy() {
+        let loaded = false;
+
+        try {
+            await this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null);
+            loaded = true;
+        } catch (e) {
+            // Ignore timeouts and install signals as normal, because with high
+            // probability the service will appear later on, and we will get a
+            // NameOwnerChanged which will finish loading
+            //
+            // (But still _initialized to false, because the proxy does not know
+            // about the HasCalendars property and would cause an exception trying
+            // to read it)
+            if (!e.matches(Gio.DBusError, Gio.DBusError.TIMED_OUT)) {
+                log('Error loading calendars: %s'.format(e.message));
+                return;
             }
+        }
 
-            this._dbusProxy.connectSignal('Changed', this._onChanged.bind(this));
-
-            this._dbusProxy.connect('notify::g-name-owner', () => {
-                if (this._dbusProxy.g_name_owner)
-                    this._onNameAppeared();
-                else
-                    this._onNameVanished();
-            });
-
-            this._dbusProxy.connect('g-properties-changed', () => {
-                this.notify('has-calendars');
-            });
+        this._dbusProxy.connectSignal('Changed', this._onChanged.bind(this));
 
-            this._initialized = loaded;
-            if (loaded) {
-                this.notify('has-calendars');
+        this._dbusProxy.connect('notify::g-name-owner', () => {
+            if (this._dbusProxy.g_name_owner)
                 this._onNameAppeared();
-            }
+            else
+                this._onNameVanished();
+        });
+
+        this._dbusProxy.connect('g-properties-changed', () => {
+            this.notify('has-calendars');
         });
+
+        this._initialized = loaded;
+        if (loaded) {
+            this.notify('has-calendars');
+            this._onNameAppeared();
+        }
     }
 
     destroy() {