[gnome-shell] remoteSearch: Stop using callback to return loaded providers
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] remoteSearch: Stop using callback to return loaded providers
- Date: Mon, 1 Aug 2022 18:55:46 +0000 (UTC)
commit 1cce999c30ea1f471b135549f269dd073ab49612
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jun 23 18:17:57 2022 +0200
remoteSearch: Stop using callback to return loaded providers
Provider loading has been synchronous since 2013, so we can
just as well return the results directly instead of passing
them to a callback.
Even if we returned to asynchronous loading in the future,
we wouldn't want to use a callback, but make the function
itself async.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>
js/ui/remoteSearch.js | 16 ++++++++++------
js/ui/search.js | 5 ++---
2 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js
index 8ebb550520..d9eef287f1 100644
--- a/js/ui/remoteSearch.js
+++ b/js/ui/remoteSearch.js
@@ -60,7 +60,13 @@ const SearchProvider2Iface = `
var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface);
var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface);
-function loadRemoteSearchProviders(searchSettings, callback) {
+/**
+ * loadRemoteSearchProviders:
+ *
+ * @param {Gio.Settings} searchSettings - search settings
+ * @returns {RemoteSearchProvider[]} - the list of remote providers
+ */
+function loadRemoteSearchProviders(searchSettings) {
let objectPaths = {};
let loadedProviders = [];
@@ -130,10 +136,8 @@ function loadRemoteSearchProviders(searchSettings, callback) {
}
}
- if (searchSettings.get_boolean('disable-external')) {
- callback([]);
- return;
- }
+ if (searchSettings.get_boolean('disable-external'))
+ return [];
FileUtils.collectFromDatadirs('search-providers', false, loadRemoteSearchProvider);
@@ -184,7 +188,7 @@ function loadRemoteSearchProviders(searchSettings, callback) {
return idxA - idxB;
});
- callback(loadedProviders);
+ return loadedProviders;
}
var RemoteSearchProvider = class {
diff --git a/js/ui/search.js b/js/ui/search.js
index 3bfb83f9f7..5375e7fc62 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -615,9 +615,8 @@ var SearchResultsView = GObject.registerClass({
this._unregisterProvider(provider);
});
- RemoteSearch.loadRemoteSearchProviders(this._searchSettings, providers => {
- providers.forEach(this._registerProvider.bind(this));
- });
+ const providers = RemoteSearch.loadRemoteSearchProviders(this._searchSettings);
+ providers.forEach(this._registerProvider.bind(this));
}
_registerProvider(provider) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]