@@ -32,7 +32,7 @@ export default class SemanticSearch extends Component {
3232 constructor () {
3333 super (... arguments );
3434 this .appEvents .on (" full-page-search:trigger-search" , this , this .onSearch );
35- this .handleSearch ();
35+ this .onSearch ();
3636 }
3737
3838 willDestroy () {
@@ -42,10 +42,14 @@ export default class SemanticSearch extends Component {
4242
4343 @action
4444 onSearch () {
45- if (! this .searching ) {
46- this .resetAiResults ();
47- return this .performHyDESearch ();
45+ if (! this .searchEnabled ) {
46+ return ;
4847 }
48+
49+ this .initialSearchTerm = this .args .outletArgs .search ;
50+ this .searching = true ;
51+ this .resetAiResults ();
52+ return this .performHyDESearch ();
4953 }
5054
5155 get disableToggleSwitch () {
@@ -69,30 +73,28 @@ export default class SemanticSearch extends Component {
6973 );
7074 }
7175
72- // Search results:
73- if (this .AiResults .length > 0 ) {
74- if (this .showingAiResults ) {
75- return I18n .t (
76- " discourse_ai.embeddings.semantic_search_results.toggle" ,
77- {
78- count: this .AiResults .length ,
79- }
80- );
81- } else {
82- return I18n .t (
83- " discourse_ai.embeddings.semantic_search_results.toggle_hidden" ,
84- {
85- count: this .AiResults .length ,
86- }
87- );
88- }
89- }
90-
9176 // Search loading:
9277 if (this .searching ) {
9378 return I18n .t (" discourse_ai.embeddings.semantic_search_loading" );
9479 }
9580
81+ // We have results and we are showing them
82+ if (this .AiResults .length && this .showingAiResults ) {
83+ return I18n .t (" discourse_ai.embeddings.semantic_search_results.toggle" , {
84+ count: this .AiResults .length ,
85+ });
86+ }
87+
88+ // We have results but are hiding them
89+ if (this .AiResults .length && ! this .showingAiResults ) {
90+ return I18n .t (
91+ " discourse_ai.embeddings.semantic_search_results.toggle_hidden" ,
92+ {
93+ count: this .AiResults .length ,
94+ }
95+ );
96+ }
97+
9698 // Typing to search:
9799 if (
98100 this .AiResults .length === 0 &&
@@ -140,18 +142,6 @@ export default class SemanticSearch extends Component {
140142 this .args .outletArgs .addSearchResults ([], " topic_id" );
141143 }
142144
143- @action
144- handleSearch () {
145- if (! this .searchEnabled ) {
146- return ;
147- }
148-
149- if (this .initialSearchTerm ) {
150- this .searching = true ;
151- return this .performHyDESearch ();
152- }
153- }
154-
155145 performHyDESearch () {
156146 this .resetAiResults ();
157147
@@ -182,7 +172,7 @@ export default class SemanticSearch extends Component {
182172 this .sortOrder = this .args .outletArgs .sortOrder ;
183173
184174 if (this .validSearchOrder ) {
185- this .handleSearch ();
175+ this .onSearch ();
186176 } else {
187177 this .showingAiResults = false ;
188178 this .resetAiResults ();
@@ -195,7 +185,9 @@ export default class SemanticSearch extends Component {
195185 <div class =" semantic-search__container search-results" role =" region" >
196186 <div class =" semantic-search__results" >
197187 <div
198- class =" semantic-search__searching {{if this . searching ' in-progress' }} "
188+ class =" semantic-search__searching
189+ {{if this . searching ' in-progress' }}
190+ {{unless this . validSearchOrder ' unavailable' }} "
199191 >
200192 <DToggleSwitch
201193 disabled ={{this .disableToggleSwitch }}
@@ -209,14 +201,15 @@ export default class SemanticSearch extends Component {
209201 {{this .searchStateText }}
210202 </div >
211203
212- <AiIndicatorWave @ loading ={{this .searching }} />
204+ {{#if this . validSearchOrder }}
205+ <AiIndicatorWave @ loading ={{this .searching }} />
206+ {{/if }}
213207
214208 {{#unless this . validSearchOrder }}
215209
216210 <DTooltip
217211 @ identifier =" semantic-search-unavailable-tooltip"
218212 class =" semantic-search__unavailable-tooltip"
219- ...attributes
220213 >
221214 <: trigger >
222215 {{icon " far-circle-question" }}
0 commit comments