DEV: Update modifyClass calls
- Update `controller:topic` modification to native class syntax - Remove search-result-entry modification in favour of plugin-outlet-based solution
This commit is contained in:
parent
0abd4b1244
commit
593e8dc2a5
|
@ -1,10 +1,16 @@
|
||||||
|
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||||
import icon from "discourse-common/helpers/d-icon";
|
import icon from "discourse-common/helpers/d-icon";
|
||||||
import i18n from "discourse-common/helpers/i18n";
|
import i18n from "discourse-common/helpers/i18n";
|
||||||
|
|
||||||
|
function addResultClass(element) {
|
||||||
|
element.closest(".fps-result")?.classList.add("ai-result");
|
||||||
|
}
|
||||||
|
|
||||||
const SearchResultDecoration = <template>
|
const SearchResultDecoration = <template>
|
||||||
<div
|
<div
|
||||||
class="ai-result__icon"
|
class="ai-result__icon"
|
||||||
title={{i18n "discourse_ai.embeddings.ai_generated_result"}}
|
title={{i18n "discourse_ai.embeddings.ai_generated_result"}}
|
||||||
|
{{didInsert addResultClass}}
|
||||||
>
|
>
|
||||||
{{icon "discourse-sparkles"}}
|
{{icon "discourse-sparkles"}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,14 +26,16 @@ function attachHeaderIcon(api) {
|
||||||
function initializeAIBotReplies(api) {
|
function initializeAIBotReplies(api) {
|
||||||
initializePauseButton(api);
|
initializePauseButton(api);
|
||||||
|
|
||||||
api.modifyClass("controller:topic", {
|
api.modifyClass(
|
||||||
pluginId: "discourse-ai",
|
"controller:topic",
|
||||||
|
(Superclass) =>
|
||||||
onAIBotStreamedReply: function (data) {
|
class extends Superclass {
|
||||||
|
onAIBotStreamedReply(data) {
|
||||||
streamPostText(this.model.postStream, data);
|
streamPostText(this.model.postStream, data);
|
||||||
},
|
}
|
||||||
subscribe: function () {
|
|
||||||
this._super();
|
subscribe() {
|
||||||
|
super.subscribe();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.model.isPrivateMessage &&
|
this.model.isPrivateMessage &&
|
||||||
|
@ -48,12 +50,14 @@ function initializeAIBotReplies(api) {
|
||||||
-2
|
-2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
unsubscribe: function () {
|
|
||||||
|
unsubscribe() {
|
||||||
this.messageBus.unsubscribe("discourse-ai/ai-bot/topic/*");
|
this.messageBus.unsubscribe("discourse-ai/ai-bot/topic/*");
|
||||||
this._super();
|
super.unsubscribe();
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializePersonaDecorator(api) {
|
function initializePersonaDecorator(api) {
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
import { apiInitializer } from "discourse/lib/api";
|
|
||||||
|
|
||||||
export default apiInitializer("1.15.0", (api) => {
|
|
||||||
api.modifyClass("component:search-result-entry", {
|
|
||||||
pluginId: "discourse-ai",
|
|
||||||
|
|
||||||
classNameBindings: ["bulkSelectEnabled", "post.generatedByAi:ai-result"],
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in New Issue