FIX: Prevent no results label from showing when untrue (#384)

This commit is contained in:
Keegan George 2023-12-27 16:42:13 -08:00 committed by GitHub
parent 76f7940b55
commit 5f088b12a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 12 deletions

View File

@ -35,17 +35,7 @@ export default class SemanticSearch extends Component {
}
get searchStateText() {
if (this.preventAISearch) {
return I18n.t("discourse_ai.embeddings.semantic_search_disabled_sort");
}
if (this.searching) {
return I18n.t("discourse_ai.embeddings.semantic_search_loading");
}
if (this.AIResults.length === 0) {
return I18n.t("discourse_ai.embeddings.semantic_search_results.none");
}
// Search results:
if (this.AIResults.length > 0) {
if (this.showingAIResults) {
return I18n.t(
@ -63,12 +53,34 @@ export default class SemanticSearch extends Component {
);
}
}
// Search disabled for sort order:
if (this.preventAISearch) {
return I18n.t("discourse_ai.embeddings.semantic_search_disabled_sort");
}
// Search loading:
if (this.searching) {
return I18n.t("discourse_ai.embeddings.semantic_search_loading");
}
// Typing to search:
if (
this.AIResults.length === 0 &&
this.searchTerm !== this.initialSearchTerm
) {
return I18n.t("discourse_ai.embeddings.semantic_search_results.new");
}
// No results:
if (this.AIResults.length === 0) {
return I18n.t("discourse_ai.embeddings.semantic_search_results.none");
}
}
get searchTerm() {
if (this.initialSearchTerm !== this.args.outletArgs.search) {
this.initialSearchTerm = undefined;
this.resetAIResults();
}
return this.args.outletArgs.search;
@ -116,6 +128,8 @@ export default class SemanticSearch extends Component {
return this.performHyDESearch();
}
this.resetAIResults();
withPluginApi("1.15.0", (api) => {
api.onAppEvent("full-page-search:trigger-search", () => {
return this.performHyDESearch();

View File

@ -172,6 +172,7 @@ en:
toggle: "Showing %{count} results found using AI"
toggle_hidden: "Hiding %{count} results found using AI"
none: "Sorry, our AI search found no matching topics."
new: "Press 'Search' to begin looking for new results with AI"
ai_generated_result: "Search result found using AI"
ai_bot: