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

@ -10,14 +10,10 @@ const FileUtils = imports.misc.fileUtils;
const Main = imports.ui.main;
const ModalDialog = imports.ui.modalDialog;
Gio._promisify(Soup.Session.prototype,
'send_and_read_async', 'send_and_read_finish');
Gio._promisify(Gio.OutputStream.prototype,
'write_bytes_async', 'write_bytes_finish');
Gio._promisify(Gio.IOStream.prototype,
'close_async', 'close_finish');
Gio._promisify(Gio.Subprocess.prototype,
'wait_check_async', 'wait_check_finish');
Gio._promisify(Soup.Session.prototype, 'send_and_read_async');
Gio._promisify(Gio.OutputStream.prototype, 'write_bytes_async');
Gio._promisify(Gio.IOStream.prototype, 'close_async');
Gio._promisify(Gio.Subprocess.prototype, 'wait_check_async');
var REPOSITORY_URL_DOWNLOAD = 'https://extensions.gnome.org/download-extension/%s.shell-extension.zip';
var REPOSITORY_URL_INFO = 'https://extensions.gnome.org/extension-info/';