Fix sending space emoji in message
This commit is contained in:
parent
46a72ae098
commit
7abd8aebe0
3 changed files with 16 additions and 8 deletions
|
@ -214,7 +214,7 @@ function getRelevantPacks(mx, rooms) {
|
|||
);
|
||||
}
|
||||
|
||||
function getShortcodeToEmoji(room) {
|
||||
function getShortcodeToEmoji(mx, rooms) {
|
||||
const allEmoji = new Map();
|
||||
|
||||
emojis.forEach((emoji) => {
|
||||
|
@ -227,7 +227,7 @@ function getShortcodeToEmoji(room) {
|
|||
}
|
||||
});
|
||||
|
||||
getRelevantPacks(room.client, [room])
|
||||
getRelevantPacks(mx, rooms)
|
||||
.flatMap((pack) => pack.getEmojis())
|
||||
.forEach((emoji) => {
|
||||
allEmoji.set(emoji.shortcode, emoji);
|
||||
|
|
|
@ -67,7 +67,7 @@ class InitMatrix extends EventEmitter {
|
|||
if (prevState === null) {
|
||||
this.roomList = new RoomList(this.matrixClient);
|
||||
this.accountData = new AccountData(this.roomList);
|
||||
this.roomsInput = new RoomsInput(this.matrixClient);
|
||||
this.roomsInput = new RoomsInput(this.matrixClient, this.roomList);
|
||||
this.notifications = new Notifications(this.roomList);
|
||||
this.emit('init_loading_finished');
|
||||
}
|
||||
|
|
|
@ -113,8 +113,11 @@ function bindReplyToContent(roomId, reply, content) {
|
|||
//
|
||||
// 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);
|
||||
function formatAndEmojifyText(mx, roomList, roomId, text) {
|
||||
const room = mx.getRoom(roomId);
|
||||
const parentIds = roomList.getAllParentSpaces(roomId);
|
||||
const parentRooms = [...parentIds].map((id) => mx.getRoom(id));
|
||||
const allEmoji = getShortcodeToEmoji(mx, [room, ...parentRooms]);
|
||||
|
||||
// Start by applying markdown formatting (if relevant)
|
||||
let formattedText;
|
||||
|
@ -158,10 +161,11 @@ function formatAndEmojifyText(room, text) {
|
|||
}
|
||||
|
||||
class RoomsInput extends EventEmitter {
|
||||
constructor(mx) {
|
||||
constructor(mx, roomList) {
|
||||
super();
|
||||
|
||||
this.matrixClient = mx;
|
||||
this.roomList = roomList;
|
||||
this.roomIdToInput = new Map();
|
||||
}
|
||||
|
||||
|
@ -262,7 +266,9 @@ class RoomsInput extends EventEmitter {
|
|||
|
||||
// Apply formatting if relevant
|
||||
const formattedBody = formatAndEmojifyText(
|
||||
this.matrixClient.getRoom(roomId),
|
||||
this.matrixClient,
|
||||
this.roomList,
|
||||
roomId,
|
||||
input.message,
|
||||
);
|
||||
if (formattedBody !== input.message) {
|
||||
|
@ -401,7 +407,9 @@ class RoomsInput extends EventEmitter {
|
|||
|
||||
// Apply formatting if relevant
|
||||
const formattedBody = formatAndEmojifyText(
|
||||
this.matrixClient.getRoom(roomId),
|
||||
this.matrixClient,
|
||||
this.roomList,
|
||||
roomId,
|
||||
editedBody,
|
||||
);
|
||||
if (formattedBody !== editedBody) {
|
||||
|
|
Loading…
Reference in a new issue