appIndicator: Check needed properties waiting for completion and errors
Marco Trevisan (TreviƱo)
1 year, 7 months ago
39 | 39 | PromiseUtils._promisify(Gio.DBusProxy.prototype, 'init_async', 'init_finish'); |
40 | 40 | |
41 | 41 | const MAX_UPDATE_FREQUENCY = 100; // In ms |
42 | const NEEDED_PROPERTIES = ['Id', 'Menu']; | |
42 | 43 | |
43 | 44 | // eslint-disable-next-line no-unused-vars |
44 | 45 | const SNICategory = { |
104 | 105 | await this._proxy.init_async(GLib.PRIORITY_DEFAULT, cancellable); |
105 | 106 | this._setupProxyAsyncMethods(); |
106 | 107 | this._checkIfReady(); |
107 | this._checkNeededProperties(); | |
108 | await this._checkNeededProperties(); | |
108 | 109 | } catch (e) { |
109 | 110 | if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) |
110 | 111 | Util.Logger.warn(`While initalizing proxy for ${this._uniqueId}: ${e}`); |
155 | 156 | return true; |
156 | 157 | |
157 | 158 | const cancellable = this._cancellable; |
158 | for (let checks = 0; checks < 3 && !this.isReady; ++checks) { | |
159 | for (let checks = 0; checks < 3; ++checks) { | |
159 | 160 | this._delayCheck = new PromiseUtils.TimeoutSecondsPromise(1, |
160 | 161 | GLib.PRIORITY_DEFAULT_IDLE, cancellable); |
161 | 162 | // eslint-disable-next-line no-await-in-loop |
162 | 163 | await this._delayCheck; |
163 | Util.refreshPropertyOnProxy(this._proxy, 'Id'); | |
164 | Util.refreshPropertyOnProxy(this._proxy, 'Menu'); | |
164 | // eslint-disable-next-line no-await-in-loop | |
165 | await Promise.all(NEEDED_PROPERTIES.map(p => | |
166 | Util.refreshPropertyOnProxy(this._proxy, p))); | |
167 | ||
168 | if (this.id && this.menuPath) | |
169 | break; | |
165 | 170 | } |
166 | 171 | |
167 | 172 | return this.id && this.menuPath; |