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'}}"
|
||||
>
|
||||
<DToggleSwitch
|
||||
disabled={{this.searching}}
|
||||
disabled={{this.disableToggleSwitch}}
|
||||
@state={{this.showingAIResults}}
|
||||
title="AI search results hidden"
|
||||
class="semantic-search__results-toggle"
|
||||
|
@ -65,6 +65,12 @@ export default class SemanticSearch extends Component {
|
|||
@tracked AIResults = [];
|
||||
@tracked showingAIResults = false;
|
||||
|
||||
get disableToggleSwitch() {
|
||||
if (this.searching || this.AIResults.length === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
get searchStateText() {
|
||||
if (this.searching) {
|
||||
return I18n.t("discourse_ai.embeddings.semantic_search_loading");
|
||||
|
@ -133,12 +139,18 @@ export default class SemanticSearch extends Component {
|
|||
})
|
||||
.then(async (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.AIResults = AIResults;
|
||||
this.args.outletArgs.addSearchResults(model.posts, "topic_id");
|
||||
this.AIResults = model.posts;
|
||||
})
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => (this.searching = false));
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
|
||||
.ai-result {
|
||||
display: none;
|
||||
background: var(--tertiary-very-low);
|
||||
border-radius: var(--d-border-radius);
|
||||
|
||||
.ai-result__icon {
|
||||
|
|
Loading…
Reference in New Issue