[gnome-shell] search: Allow synchronous searches to be defined with the async API



commit 0bf6c93faa724afc2b972107f240d4976faa9e7f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed May 2 15:26:54 2012 -0400

    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

 js/ui/search.js |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/search.js b/js/ui/search.js
index 1d654fb..b2348d5 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -379,14 +379,19 @@ const SearchSystem = new Lang.Class({
             }
         }
 
+        let previousResultsArr = this._previousResults;
+
         let results = [];
+        this._previousTerms = terms;
+        this._previousResults = results;
+
         if (isSubSearch) {
             for (let i = 0; i < this._providers.length; i++) {
-                let [provider, previousResults] = this._previousResults[i];
+                let [provider, previousResults] = previousResultsArr[i];
                 try {
                     if (provider.async) {
-                        provider.getSubsearchResultSetAsync(previousResults, terms);
                         results.push([provider, []]);
+                        provider.getSubsearchResultSetAsync(previousResults, terms);
                     } else {
                         let providerResults = provider.getSubsearchResultSet(previousResults, terms);
                         results.push([provider, providerResults]);
@@ -400,8 +405,8 @@ const SearchSystem = new Lang.Class({
                 let provider = this._providers[i];
                 try {
                     if (provider.async) {
-                        provider.getInitialResultSetAsync(terms);
                         results.push([provider, []]);
+                        provider.getInitialResultSetAsync(terms);
                     } else {
                         let providerResults = provider.getInitialResultSet(terms);
                         results.push([provider, providerResults]);
@@ -412,8 +417,6 @@ const SearchSystem = new Lang.Class({
             }
         }
 
-        this._previousTerms = terms;
-        this._previousResults = results;
         this.emit('search-completed', results);
     },
 });



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]