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>
This commit is contained in:
Florian Müllner 2022-06-23 18:17:57 +02:00 committed by Marge Bot
parent 4880364cd2
commit 1cce999c30
2 changed files with 12 additions and 9 deletions

View File

@ -60,7 +60,13 @@ const SearchProvider2Iface = `
var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface); var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface);
var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface); 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 objectPaths = {};
let loadedProviders = []; let loadedProviders = [];
@ -130,10 +136,8 @@ function loadRemoteSearchProviders(searchSettings, callback) {
} }
} }
if (searchSettings.get_boolean('disable-external')) { if (searchSettings.get_boolean('disable-external'))
callback([]); return [];
return;
}
FileUtils.collectFromDatadirs('search-providers', false, loadRemoteSearchProvider); FileUtils.collectFromDatadirs('search-providers', false, loadRemoteSearchProvider);
@ -184,7 +188,7 @@ function loadRemoteSearchProviders(searchSettings, callback) {
return idxA - idxB; return idxA - idxB;
}); });
callback(loadedProviders); return loadedProviders;
} }
var RemoteSearchProvider = class { var RemoteSearchProvider = class {

View File

@ -615,9 +615,8 @@ var SearchResultsView = GObject.registerClass({
this._unregisterProvider(provider); this._unregisterProvider(provider);
}); });
RemoteSearch.loadRemoteSearchProviders(this._searchSettings, providers => { const providers = RemoteSearch.loadRemoteSearchProviders(this._searchSettings);
providers.forEach(this._registerProvider.bind(this)); providers.forEach(this._registerProvider.bind(this));
});
} }
_registerProvider(provider) { _registerProvider(provider) {