Skip to content

Commit

Permalink
DEV: Use the new modifyClass api
Browse files Browse the repository at this point in the history
  • Loading branch information
CvX committed Dec 22, 2023
1 parent 933cfd6 commit 0c30948
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions javascripts/discourse/initializers/gif-integration.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { withPluginApi } from "discourse/lib/plugin-api";
import ChatComposer from "discourse/plugins/chat/discourse/components/chat-composer";
import GifModal from "../components/modal/gif";

export default {
Expand Down Expand Up @@ -35,24 +36,28 @@ export default {
position: "dropdown",
});

api.modifyClass("component:chat-composer", {
pluginId: "discourse-gifs",
api.modifyClass(
ChatComposer,
(Base) =>
class extends Base {
@service modal;

@action
showChatGifModal(context) {
this.modal.show(GifModal, {
model: {
customPickHandler: (message) => {
api.sendChatMessage(this.draft.channel.id, {
message,
threadId:
context === "thread" ? this.draft.thread.id : null,
});
},
},
});
},
});
@action
showChatGifModal(context) {
this.modal.show(GifModal, {
model: {
customPickHandler: (message) => {
api.sendChatMessage(this.draft.channel.id, {
message,
threadId:
context === "thread" ? this.draft.thread.id : null,
});
},
},
});
}
}
);
}
});

Expand Down

0 comments on commit 0c30948

Please sign in to comment.