From 6244ce44f510afd740a8abace64c338645fe6fe7 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Wed, 20 Mar 2024 17:20:19 +0800 Subject: [PATCH] utils: Override async functions with async functions Otherwise gnome-shell (LayoutManager._loadBackground) can't find the override when it was expecting an async function. Closes: https://github.com/micheleg/dash-to-dock/issues/2110 --- utils.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/utils.js b/utils.js index bc4eb7705..85a582185 100644 --- a/utils.js +++ b/utils.js @@ -322,9 +322,16 @@ export class InjectionsHandler extends BasicHandler { if (!(original instanceof Function)) throw new Error(`Virtual function ${name}() is not available for ${object}`); - object[name] = function (...args) { - return injectedFunction.call(this, original, ...args); - }; + if (original.constructor.name === 'AsyncFunction') { + // eslint-disable-next-line require-await + object[name] = async function (...args) { + return injectedFunction.call(this, original, ...args); + }; + } else { + object[name] = function (...args) { + return injectedFunction.call(this, original, ...args); + }; + } return [object, name, original]; }