search: Allow synchronous searches to be defined with the async API

To allow this to happen, we need to make sure that we don't overwrite the
previousResults when calling the async method. Note that this is a bug of
some sort, we were already using this synchronous style when a remote
search failed.

https://bugzilla.gnome.org/show_bug.cgi?id=675328
This commit is contained in:
Jasper St. Pierre 2012-05-02 15:26:54 -04:00
parent b9f0158278
commit 0bf6c93faa

View File

@ -379,14 +379,19 @@ const SearchSystem = new Lang.Class({
} }
} }
let previousResultsArr = this._previousResults;
let results = []; let results = [];
this._previousTerms = terms;
this._previousResults = results;
if (isSubSearch) { if (isSubSearch) {
for (let i = 0; i < this._providers.length; i++) { for (let i = 0; i < this._providers.length; i++) {
let [provider, previousResults] = this._previousResults[i]; let [provider, previousResults] = previousResultsArr[i];
try { try {
if (provider.async) { if (provider.async) {
provider.getSubsearchResultSetAsync(previousResults, terms);
results.push([provider, []]); results.push([provider, []]);
provider.getSubsearchResultSetAsync(previousResults, terms);
} else { } else {
let providerResults = provider.getSubsearchResultSet(previousResults, terms); let providerResults = provider.getSubsearchResultSet(previousResults, terms);
results.push([provider, providerResults]); results.push([provider, providerResults]);
@ -400,8 +405,8 @@ const SearchSystem = new Lang.Class({
let provider = this._providers[i]; let provider = this._providers[i];
try { try {
if (provider.async) { if (provider.async) {
provider.getInitialResultSetAsync(terms);
results.push([provider, []]); results.push([provider, []]);
provider.getInitialResultSetAsync(terms);
} else { } else {
let providerResults = provider.getInitialResultSet(terms); let providerResults = provider.getInitialResultSet(terms);
results.push([provider, providerResults]); results.push([provider, providerResults]);
@ -412,8 +417,6 @@ const SearchSystem = new Lang.Class({
} }
} }
this._previousTerms = terms;
this._previousResults = results;
this.emit('search-completed', results); this.emit('search-completed', results);
}, },
}); });