diff --git a/src/app/organisms/emoji-board/custom-emoji.js b/src/app/organisms/emoji-board/custom-emoji.js
index 85b3d3969a..080b25e314 100644
--- a/src/app/organisms/emoji-board/custom-emoji.js
+++ b/src/app/organisms/emoji-board/custom-emoji.js
@@ -71,9 +71,7 @@ function getUserEmoji(mx) {
// Returns a list of `ImagePack`s. This does not include packs in spaces that contain
// this room.
function getPacksInRoom(room) {
- const packs = room.currentState
- .events
- .get('im.ponies.room_emotes');
+ const packs = room.currentState.getStateEvents('im.ponies.room_emotes')
if (!packs) {
return [];
diff --git a/src/client/state/RoomsInput.js b/src/client/state/RoomsInput.js
index 053e505b94..6036d25095 100644
--- a/src/client/state/RoomsInput.js
+++ b/src/client/state/RoomsInput.js
@@ -113,6 +113,54 @@ function bindReplyToContent(roomId, reply, content) {
return newContent;
}
+// Apply formatting to a plain text message
+//
+// This includes inserting any custom emoji that might be relevant, and (only if the
+// user has enabled it in their settings) formatting the message using markdown.
+function formatAndEmojifyText(room, text) {
+ const allEmoji = getShortcodeToEmoji(room);
+
+ // Start by applying markdown formatting (if relevant)
+ let formattedText;
+ if (settings.isMarkdown) {
+ formattedText = getFormattedBody(text);
+ } else {
+ formattedText = text;
+ }
+
+ // Check to see if there are any :shortcode-style-tags: in the message
+ Array.from(formattedText.matchAll(/\B:([\w-]+):\B/g))
+ // Then filter to only the ones corresponding to a valid emoji
+ .filter((match) => allEmoji.has(match[1]))
+ // Reversing the array ensures that indices are preserved as we start replacing
+ .reverse()
+ // Replace each :shortcode: with an tag
+ .forEach((shortcodeMatch) => {
+ const emoji = allEmoji.get(shortcodeMatch[1]);
+
+ // Render the tag that will replace the shortcode
+ let tag;
+ if (emoji.mxc) {
+ tag = ``;
+ } else {
+ tag = emoji.unicode;
+ }
+
+ // Splice the tag into the text
+ formattedText = formattedText.substr(0, shortcodeMatch.index)
+ + tag
+ + formattedText.substr(shortcodeMatch.index + shortcodeMatch[0].length);
+ });
+
+ return formattedText;
+}
+
class RoomsInput extends EventEmitter {
constructor(mx) {
super();
@@ -201,54 +249,6 @@ class RoomsInput extends EventEmitter {
return this.roomIdToInput.get(roomId)?.isSending || false;
}
- // Apply formatting to a plain text message
- //
- // This includes inserting any custom emoji that might be relevant, and (only if the
- // user has enabled it in their settings) formatting the message using markdown.
- static formatAndEmojifyText(room, text) {
- const allEmoji = getShortcodeToEmoji(room);
-
- // Start by applying markdown formatting (if relevant)
- let formattedText;
- if (settings.isMarkdown) {
- formattedText = getFormattedBody(text);
- } else {
- formattedText = text;
- }
-
- // Check to see if there are any :shortcode-style-tags: in the message
- Array.from(formattedText.matchAll(/\B:([\w-]+):\B/g))
- // Then filter to only the ones corresponding to a valid emoji
- .filter((match) => allEmoji.has(match[1]))
- // Reversing the array ensures that indices are preserved as we start replacing
- .reverse()
- // Replace each :shortcode: with an tag
- .forEach((shortcodeMatch) => {
- const emoji = allEmoji.get(shortcodeMatch[1]);
-
- // Render the tag that will replace the shortcode
- let tag;
- if (emoji.mxc) {
- tag = ``;
- } else {
- tag = emoji.unicode;
- }
-
- // Splice the tag into the text
- formattedText = formattedText.substr(0, shortcodeMatch.index)
- + tag
- + formattedText.substr(shortcodeMatch.index + shortcodeMatch[0].length);
- });
-
- return formattedText;
- }
-
async sendInput(roomId) {
const input = this.getInput(roomId);
input.isSending = true;
@@ -265,7 +265,7 @@ class RoomsInput extends EventEmitter {
};
// Apply formatting if relevant
- const formattedBody = RoomsInput.formatAndEmojifyText(
+ const formattedBody = formatAndEmojifyText(
this.matrixClient.getRoom(roomId),
input.message,
);
@@ -404,7 +404,7 @@ class RoomsInput extends EventEmitter {
};
// Apply formatting if relevant
- const formattedBody = this.formatAndEmojifyText(editedBody);
+ const formattedBody = formatAndEmojifyText(editedBody);
if (formattedBody !== editedBody) {
content.formatted_body = ` * ${formattedBody}`;
content.format = 'org.matrix.custom.html';