Themes: Avoid announcing the theme search results too many times.
Props afercia. Fixes #36848. git-svn-id: https://develop.svn.wordpress.org/trunk@37967 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
727b070c60
commit
13896fc5de
@ -1103,7 +1103,13 @@ themes.view.Themes = wp.Backbone.View.extend({
|
|||||||
this.liveThemeCount = this.collection.count ? this.collection.count : this.collection.length;
|
this.liveThemeCount = this.collection.count ? this.collection.count : this.collection.length;
|
||||||
this.count.text( this.liveThemeCount );
|
this.count.text( this.liveThemeCount );
|
||||||
|
|
||||||
this.announceSearchResults( this.liveThemeCount );
|
/*
|
||||||
|
* In the theme installer the themes count is already announced
|
||||||
|
* because `announceSearchResults` is called on `query:success`.
|
||||||
|
*/
|
||||||
|
if ( ! themes.isInstall ) {
|
||||||
|
this.announceSearchResults( this.liveThemeCount );
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Iterates through each instance of the collection
|
// Iterates through each instance of the collection
|
||||||
@ -1459,6 +1465,8 @@ themes.view.InstallerSearch = themes.view.Search.extend({
|
|||||||
'keyup': 'search'
|
'keyup': 'search'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
terms: '',
|
||||||
|
|
||||||
// Handles Ajax request for searching through themes in public repo
|
// Handles Ajax request for searching through themes in public repo
|
||||||
search: function( event ) {
|
search: function( event ) {
|
||||||
|
|
||||||
@ -1480,6 +1488,14 @@ themes.view.InstallerSearch = themes.view.Search.extend({
|
|||||||
doSearch: _.debounce( function( value ) {
|
doSearch: _.debounce( function( value ) {
|
||||||
var request = {};
|
var request = {};
|
||||||
|
|
||||||
|
// Don't do anything if the search terms haven't changed.
|
||||||
|
if ( this.terms === value ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Updates terms with the value passed.
|
||||||
|
this.terms = value;
|
||||||
|
|
||||||
request.search = value;
|
request.search = value;
|
||||||
|
|
||||||
// Intercept an [author] search.
|
// Intercept an [author] search.
|
||||||
|
Loading…
Reference in New Issue
Block a user