From 9828094d2cccd777001776086849397e038467b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 10 Aug 2022 22:27:21 +0200 Subject: Gio: Simplify init_async usage by always using a promise The function is defined as a so we can just rely on promise syntax to handle the results. --- modules/core/overrides/Gio.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/core/overrides/Gio.js b/modules/core/overrides/Gio.js index 1fab4796..becefa03 100644 --- a/modules/core/overrides/Gio.js +++ b/modules/core/overrides/Gio.js @@ -247,19 +247,8 @@ function _makeProxyWrapper(interfaceXml) { if (!cancellable) cancellable = null; if (asyncCallback) { - obj.init_async(GLib.PRIORITY_DEFAULT, cancellable, (initable, result) => { - let caughtErrorWhenInitting = null; - try { - initable.init_finish(result); - } catch (e) { - caughtErrorWhenInitting = e; - } - - if (caughtErrorWhenInitting === null) - asyncCallback(initable, null); - else - asyncCallback(null, caughtErrorWhenInitting); - }); + obj.init_async(GLib.PRIORITY_DEFAULT, cancellable).then( + () => asyncCallback(obj, null)).catch(e => asyncCallback(null, e)); } else { obj.init(cancellable); } -- cgit v1.2.1