diff --git a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 index d5ba0ad2fbc..fa52b4122f9 100644 --- a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 @@ -12,6 +12,7 @@ export default Ember.Controller.extend({ selected: [], context_id: null, context: null, + searching: false, @computed('q') hasAutofocus(q) { @@ -45,9 +46,9 @@ export default Ember.Controller.extend({ return isValidSearchTerm(q); }, - @computed('searchTerm') - isNotValidSearchTerm(searchTerm) { - return !isValidSearchTerm(searchTerm); + @computed('searchTerm', 'searching') + searchButtonDisabled(searchTerm, searching) { + return !!(searching || !isValidSearchTerm(searchTerm)); }, @observes('model') @@ -74,10 +75,8 @@ export default Ember.Controller.extend({ canBulkSelect: Em.computed.alias('currentUser.staff'), search(){ - if (this._searching) { - return; - } - this._searching = true; + if (this.get("searching")) return; + this.set("searching", true); const router = Discourse.__container__.lookup('router:main'); @@ -100,7 +99,7 @@ export default Ember.Controller.extend({ const model = translateResults(results) || {}; router.transientCache('lastSearch', { searchKey, model }, 5); this.set("model", model); - }).finally(() => this._searching = false); + }).finally(() => { this.set("searching",false); }); }, actions: { @@ -139,7 +138,7 @@ export default Ember.Controller.extend({ }, search() { - if (this.get("isNotValidSearchTerm")) return; + if (this.get("searchButtonDisabled")) return; this.search(); } } diff --git a/app/assets/javascripts/discourse/lib/screen-track.js.es6 b/app/assets/javascripts/discourse/lib/screen-track.js.es6 index c8bc36fdbf3..2bc93738703 100644 --- a/app/assets/javascripts/discourse/lib/screen-track.js.es6 +++ b/app/assets/javascripts/discourse/lib/screen-track.js.es6 @@ -137,7 +137,7 @@ const ScreenTrack = Ember.Object.extend({ controller.readPosts(topicId, postNumbers); } }); - } else { + } else if (this.get('anonFlushCallback')) { // Anonymous viewer - save to localStorage const storage = this.get('keyValueStore'); @@ -158,9 +158,7 @@ const ScreenTrack = Ember.Object.extend({ } // Inform the observer - if (this.get('anonFlushCallback')) { - this.get('anonFlushCallback')(); - } + this.get('anonFlushCallback')(); // No need to call controller.readPosts() } diff --git a/app/assets/javascripts/discourse/templates/full-page-search.hbs b/app/assets/javascripts/discourse/templates/full-page-search.hbs index 8f1874345c2..65537a30216 100644 --- a/app/assets/javascripts/discourse/templates/full-page-search.hbs +++ b/app/assets/javascripts/discourse/templates/full-page-search.hbs @@ -1,6 +1,6 @@