Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit ccd9f52

Browse files
author
rngus2344
committed
compress some codes
1 parent 3c797b3 commit ccd9f52

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

assets/javascripts/discourse/components/ai-full-page-search.gjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import I18n, { i18n } from "discourse-i18n";
1313
import DTooltip from "float-kit/components/d-tooltip";
1414
import AiIndicatorWave from "./ai-indicator-wave";
1515

16+
const AI_RESULTS_TOGGLED = "full-page-search:ai-results-toggled";
17+
1618
export default class AiFullPageSearch extends Component {
1719
@service appEvents;
1820
@service router;
@@ -123,15 +125,12 @@ export default class AiFullPageSearch extends Component {
123125

124126
@action
125127
toggleAiResults() {
128+
this.appEvents.trigger(AI_RESULTS_TOGGLED, {
129+
enabled: !this.showingAiResults,
130+
});
126131
if (this.showingAiResults) {
127-
this.appEvents.trigger("full-page-search:ai-results-toggled", {
128-
enabled: false,
129-
});
130132
this.args.addSearchResults([], "topic_id");
131133
} else {
132-
this.appEvents.trigger("full-page-search:ai-results-toggled", {
133-
enabled: true,
134-
});
135134
this.args.addSearchResults(this.AiResults, "topic_id");
136135
}
137136
this.showingAiResults = !this.showingAiResults;
@@ -142,7 +141,7 @@ export default class AiFullPageSearch extends Component {
142141
this.AiResults = [];
143142
this.showingAiResults = false;
144143
this.args.addSearchResults([], "topic_id");
145-
this.appEvents.trigger("full-page-search:ai-results-toggled", {
144+
this.appEvents.trigger(AI_RESULTS_TOGGLED, {
146145
enabled: false,
147146
});
148147
}

0 commit comments

Comments
 (0)