A platform for community discussion. Free, open, simple.
DEV: Modernize chat helper definitions (#24017)
David Taylor98cb14dd82f5
diff --git a/plugins/chat/assets/javascripts/discourse/helpers/format-chat-date.js b/plugins/chat/assets/javascripts/discourse/helpers/format-chat-date.jsindex 37580a08552..fb504e08cc4 100644--- a/plugins/chat/assets/javascripts/discourse/helpers/format-chat-date.js+++ b/plugins/chat/assets/javascripts/discourse/helpers/format-chat-date.js@@ -1,10 +1,9 @@import { htmlSafe } from "@ember/template";import User from "discourse/models/user";import getURL from "discourse-common/lib/get-url";-import { registerUnbound } from "discourse-common/lib/helpers";import I18n from "discourse-i18n";-registerUnbound("format-chat-date", function (message, mode) {+export default function formatChatDate(message, mode) {const currentUser = User.current();const tz = currentUser ? currentUser.user_option.timezone : moment.tz.guess();const date = moment(new Date(message.createdAt), tz);@@ -25,4 +24,4 @@ registerUnbound("format-chat-date", function (message, mode) {`<a title='${title}' tabindex="-1" class='chat-time' href='${url}'>${display}</a>`);}-});+}diff --git a/plugins/chat/assets/javascripts/discourse/helpers/tonable-emoji-title.js b/plugins/chat/assets/javascripts/discourse/helpers/tonable-emoji-title.jsindex f1fb7642d0a..6c4c625e15d 100644--- a/plugins/chat/assets/javascripts/discourse/helpers/tonable-emoji-title.js+++ b/plugins/chat/assets/javascripts/discourse/helpers/tonable-emoji-title.js@@ -1,9 +1,7 @@-import { registerUnbound } from "discourse-common/lib/helpers";--registerUnbound("tonable-emoji-title", function (emoji, diversity) {+export default function tonableEmojiTitle(emoji, diversity) {if (!emoji.tonable || diversity === 1) {return `:${emoji.name}:`;}return `:${emoji.name}:t${diversity}:`;-});+}diff --git a/plugins/chat/assets/javascripts/discourse/helpers/tonable-emoji-url.js b/plugins/chat/assets/javascripts/discourse/helpers/tonable-emoji-url.jsindex 75e0bdc08d3..4d4aca6f301 100644--- a/plugins/chat/assets/javascripts/discourse/helpers/tonable-emoji-url.js+++ b/plugins/chat/assets/javascripts/discourse/helpers/tonable-emoji-url.js@@ -1,9 +1,7 @@-import { registerUnbound } from "discourse-common/lib/helpers";--registerUnbound("tonable-emoji-url", function (emoji, scale) {+export default function tonableEmojiUrl(emoji, scale) {if (!emoji.tonable || scale === 1) {return emoji.url;}return emoji.url.split(".png")[0] + `/${scale}.png`;-});+}