From b294ace07d009ac5a6319e7af8f7ba00c9f4f902 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 21 Jan 2025 13:04:46 +0100 Subject: [PATCH] DEV: Use the native `modifyClass` API (#61) --- .../discourse/initializers/gif-integration.js | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/javascripts/discourse/initializers/gif-integration.js b/javascripts/discourse/initializers/gif-integration.js index cdf914a..3d3f84b 100644 --- a/javascripts/discourse/initializers/gif-integration.js +++ b/javascripts/discourse/initializers/gif-integration.js @@ -1,4 +1,5 @@ import { action } from "@ember/object"; +import { service } from "@ember/service"; import { withPluginApi } from "discourse/lib/plugin-api"; import GifModal from "../components/modal/gif"; @@ -34,24 +35,28 @@ export default { position: "dropdown", }); - api.modifyClass("component:chat-composer", { - pluginId: "discourse-gifs", + api.modifyClass( + "component:chat-composer", + (Superclass) => + class extends Superclass { + @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, + }); + }, + }, + }); + } + } + ); } });