search: Always fetch the list of search providers
We fetch and store the list of providers from the search system when we construct SearchResults, but we never update this list when providers are changed at runtime, causing various bugs making the search not seem as snappy as it should be. Make sure to always fetch the list of providers from the search system.
This commit is contained in:
parent
cf7cf45003
commit
c0c20d49a5
@ -481,11 +481,9 @@ const SearchResults = new Lang.Class({
|
|||||||
y_align: St.Align.MIDDLE });
|
y_align: St.Align.MIDDLE });
|
||||||
this._content.add(this._statusBin, { expand: true });
|
this._content.add(this._statusBin, { expand: true });
|
||||||
this._statusBin.add_actor(this._statusText);
|
this._statusBin.add_actor(this._statusText);
|
||||||
this._providers = this._searchSystem.getProviders();
|
this._searchSystem.getProviders().forEach(Lang.bind(this, function(provider) {
|
||||||
this._providerDisplays = {};
|
|
||||||
for (let i = 0; i < this._providers.length; i++) {
|
|
||||||
this.createProviderDisplay(this._providers[i]);
|
this.createProviderDisplay(this._providers[i]);
|
||||||
}
|
}));
|
||||||
|
|
||||||
this._highlightDefault = false;
|
this._highlightDefault = false;
|
||||||
this._defaultResult = null;
|
this._defaultResult = null;
|
||||||
@ -503,30 +501,26 @@ const SearchResults = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
createProviderDisplay: function(provider) {
|
createProviderDisplay: function(provider) {
|
||||||
let providerDisplay = null;
|
let providerDisplay;
|
||||||
|
if (provider.appInfo)
|
||||||
if (provider.appInfo) {
|
|
||||||
providerDisplay = new ListSearchResults(provider);
|
providerDisplay = new ListSearchResults(provider);
|
||||||
} else {
|
else
|
||||||
providerDisplay = new GridSearchResults(provider);
|
providerDisplay = new GridSearchResults(provider);
|
||||||
}
|
|
||||||
|
|
||||||
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
|
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
|
||||||
this._providerDisplays[provider.id] = providerDisplay;
|
|
||||||
this._content.add(providerDisplay.actor);
|
this._content.add(providerDisplay.actor);
|
||||||
|
provider.display = providerDisplay;
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyProviderDisplay: function(provider) {
|
destroyProviderDisplay: function(provider) {
|
||||||
this._providerDisplays[provider.id].destroy();
|
provider.display.destroy();
|
||||||
delete this._providerDisplays[provider.id];
|
provider.display = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_clearDisplay: function() {
|
_clearDisplay: function() {
|
||||||
for (let i = 0; i < this._providers.length; i++) {
|
this._searchSystem.getProviders().forEach(function(provider) {
|
||||||
let provider = this._providers[i];
|
provider.display.clear();
|
||||||
let providerDisplay = this._providerDisplays[provider.id];
|
});
|
||||||
providerDisplay.clear();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
@ -545,9 +539,10 @@ const SearchResults = new Lang.Class({
|
|||||||
_maybeSetInitialSelection: function() {
|
_maybeSetInitialSelection: function() {
|
||||||
let newDefaultResult = null;
|
let newDefaultResult = null;
|
||||||
|
|
||||||
for (let i = 0; i < this._providers.length; i++) {
|
let providers = this._searchSystem.getProviders();
|
||||||
let provider = this._providers[i];
|
for (let i = 0; i < providers.length; i++) {
|
||||||
let display = this._providerDisplays[provider.id];
|
let provider = providers[i];
|
||||||
|
let display = provider.display;
|
||||||
|
|
||||||
if (!display.actor.visible)
|
if (!display.actor.visible)
|
||||||
continue;
|
continue;
|
||||||
@ -570,16 +565,10 @@ const SearchResults = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updateStatusText: function () {
|
_updateStatusText: function () {
|
||||||
let haveResults = false;
|
let haveResults = this._searchSystem.getProviders().some(function(provider) {
|
||||||
|
let display = provider.display;
|
||||||
for (let i = 0; i < this._providers.length; i++) {
|
return (display.getFirstResult() != null);
|
||||||
let provider = this._providers[i];
|
});
|
||||||
let display = this._providerDisplays[provider.id];
|
|
||||||
if (display.getFirstResult()) {
|
|
||||||
haveResults = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!haveResults) {
|
if (!haveResults) {
|
||||||
this._statusText.set_text(_("No results."));
|
this._statusText.set_text(_("No results."));
|
||||||
@ -592,7 +581,7 @@ const SearchResults = new Lang.Class({
|
|||||||
_updateResults: function(searchSystem, results) {
|
_updateResults: function(searchSystem, results) {
|
||||||
let terms = searchSystem.getTerms();
|
let terms = searchSystem.getTerms();
|
||||||
let [provider, providerResults] = results;
|
let [provider, providerResults] = results;
|
||||||
let display = this._providerDisplays[provider.id];
|
let display = provider.display;
|
||||||
|
|
||||||
display.updateSearch(providerResults, terms, Lang.bind(this, function() {
|
display.updateSearch(providerResults, terms, Lang.bind(this, function() {
|
||||||
this._maybeSetInitialSelection();
|
this._maybeSetInitialSelection();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user