FIX: Un-clickable AI Results (#298)
This commit is contained in:
parent
f7277d244e
commit
491111e5c8
|
@ -29,7 +29,7 @@ export default class SemanticSearch extends Component {
|
||||||
{{if this.searching 'in-progress'}}"
|
{{if this.searching 'in-progress'}}"
|
||||||
>
|
>
|
||||||
<DToggleSwitch
|
<DToggleSwitch
|
||||||
disabled={{this.searching}}
|
disabled={{this.disableToggleSwitch}}
|
||||||
@state={{this.showingAIResults}}
|
@state={{this.showingAIResults}}
|
||||||
title="AI search results hidden"
|
title="AI search results hidden"
|
||||||
class="semantic-search__results-toggle"
|
class="semantic-search__results-toggle"
|
||||||
|
@ -65,6 +65,12 @@ export default class SemanticSearch extends Component {
|
||||||
@tracked AIResults = [];
|
@tracked AIResults = [];
|
||||||
@tracked showingAIResults = false;
|
@tracked showingAIResults = false;
|
||||||
|
|
||||||
|
get disableToggleSwitch() {
|
||||||
|
if (this.searching || this.AIResults.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get searchStateText() {
|
get searchStateText() {
|
||||||
if (this.searching) {
|
if (this.searching) {
|
||||||
return I18n.t("discourse_ai.embeddings.semantic_search_loading");
|
return I18n.t("discourse_ai.embeddings.semantic_search_loading");
|
||||||
|
@ -133,12 +139,18 @@ export default class SemanticSearch extends Component {
|
||||||
})
|
})
|
||||||
.then(async (results) => {
|
.then(async (results) => {
|
||||||
const model = (await translateResults(results)) || {};
|
const model = (await translateResults(results)) || {};
|
||||||
const AIResults = model.posts.map(function (post) {
|
|
||||||
return Object.assign({}, post, { generatedByAI: true });
|
if (model.posts?.length === 0) {
|
||||||
|
this.searching = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.posts.forEach((post) => {
|
||||||
|
post.generatedByAI = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.args.outletArgs.addSearchResults(AIResults, "topic_id");
|
this.args.outletArgs.addSearchResults(model.posts, "topic_id");
|
||||||
this.AIResults = AIResults;
|
this.AIResults = model.posts;
|
||||||
})
|
})
|
||||||
.catch(popupAjaxError)
|
.catch(popupAjaxError)
|
||||||
.finally(() => (this.searching = false));
|
.finally(() => (this.searching = false));
|
||||||
|
|
|
@ -62,7 +62,6 @@
|
||||||
|
|
||||||
.ai-result {
|
.ai-result {
|
||||||
display: none;
|
display: none;
|
||||||
background: var(--tertiary-very-low);
|
|
||||||
border-radius: var(--d-border-radius);
|
border-radius: var(--d-border-radius);
|
||||||
|
|
||||||
.ai-result__icon {
|
.ai-result__icon {
|
||||||
|
|
Loading…
Reference in New Issue