js: Simplify promisify() calls

If the finish function isn't specified, promisify will now try
to use the async name without '_async'/'_begin' suffix (if any)
and '_finish' appended.

Everything except IBus uses a variation of that pattern, so there's
quite a bit of boilerplate we get to remove…

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2174>
This commit is contained in:
Florian Müllner
2022-02-11 00:09:54 +01:00
committed by Marge Bot
parent 928f3288e9
commit 5442266f28
14 changed files with 41 additions and 62 deletions

View File

@@ -14,8 +14,8 @@ const { ExtensionState, ExtensionType } = ExtensionUtils;
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
Gio._promisify(Shew.WindowExporter.prototype, 'export', 'export_finish');
Gio._promisify(Gio.DBusConnection.prototype, 'call');
Gio._promisify(Shew.WindowExporter.prototype, 'export');
function loadInterfaceXML(iface) {
const uri = 'resource:///org/gnome/Extensions/dbus-interfaces/%s.xml'.format(iface);