mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 10:57:04 +08:00
DEV: Modernize chat helper definitions (#24017)
These helpers are never used in raw-hbs. Exporting default functions is enough for them to be picked up by the ember resolver, and also makes it possible to use them in gjs files.
This commit is contained in:
parent
b1c6e67e2c
commit
98cb14dd82
|
@ -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>`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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}:`;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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`;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user