Codebase list gnome-shell-extension-appindicator / 9cc0a64
appIndicator: Check needed properties waiting for completion and errors Marco Trevisan (TreviƱo) 1 year, 7 months ago
1 changed file(s) with 9 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
3939 PromiseUtils._promisify(Gio.DBusProxy.prototype, 'init_async', 'init_finish');
4040
4141 const MAX_UPDATE_FREQUENCY = 100; // In ms
42 const NEEDED_PROPERTIES = ['Id', 'Menu'];
4243
4344 // eslint-disable-next-line no-unused-vars
4445 const SNICategory = {
104105 await this._proxy.init_async(GLib.PRIORITY_DEFAULT, cancellable);
105106 this._setupProxyAsyncMethods();
106107 this._checkIfReady();
107 this._checkNeededProperties();
108 await this._checkNeededProperties();
108109 } catch (e) {
109110 if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
110111 Util.Logger.warn(`While initalizing proxy for ${this._uniqueId}: ${e}`);
155156 return true;
156157
157158 const cancellable = this._cancellable;
158 for (let checks = 0; checks < 3 && !this.isReady; ++checks) {
159 for (let checks = 0; checks < 3; ++checks) {
159160 this._delayCheck = new PromiseUtils.TimeoutSecondsPromise(1,
160161 GLib.PRIORITY_DEFAULT_IDLE, cancellable);
161162 // eslint-disable-next-line no-await-in-loop
162163 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;
165170 }
166171
167172 return this.id && this.menuPath;