diff --git a/src/components/message.js b/src/components/message.js index 2edf8dc4b..4fc24a446 100644 --- a/src/components/message.js +++ b/src/components/message.js @@ -4,6 +4,7 @@ import './message-actions.js'; import MessageVersionsModal from '../modals/message-versions.js'; import dayjs from 'dayjs'; import filesize from "filesize"; +import tpl_chat_message from '../templates/chat_message.js'; import tpl_spinner from '../templates/spinner.js'; import { CustomElement } from './element.js'; import { __ } from '@converse/headless/i18n'; @@ -14,11 +15,9 @@ import { renderAvatar } from './../templates/directives/avatar'; const { Strophe } = converse.env; const u = converse.env.utils; -const i18n_edited = __('This message has been edited'); const i18n_show = __('Show more'); const i18n_show_less = __('Show less'); const i18n_uploading = __('Uploading file:'); -const i18n_new_messages = __('New messages'); class Message extends CustomElement { @@ -124,42 +123,7 @@ class Message extends CustomElement { } renderChatMessage () { - const is_groupchat_message = (this.message_type === 'groupchat'); - return html` - ${ this.is_first_unread ? html`
` : '' } - `; + return tpl_chat_message(this); } shouldShowAvatar () { diff --git a/src/templates/chat_message.js b/src/templates/chat_message.js new file mode 100644 index 000000000..cdacd3c85 --- /dev/null +++ b/src/templates/chat_message.js @@ -0,0 +1,46 @@ +import { html } from "lit-html"; +import { __ } from '@converse/headless/i18n'; +import { renderAvatar } from './../templates/directives/avatar'; + +const i18n_edited = __('This message has been edited'); +const i18n_new_messages = __('New messages'); + + +export default (o) => { + const is_groupchat_message = (o.message_type === 'groupchat'); + return html` + ${ o.is_first_unread ? html` ` : '' } + `; +}