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();
|
const allEmoji = new Map();
|
||||||
|
|
||||||
emojis.forEach((emoji) => {
|
emojis.forEach((emoji) => {
|
||||||
|
@ -227,7 +227,7 @@ function getShortcodeToEmoji(room) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
getRelevantPacks(room.client, [room])
|
getRelevantPacks(mx, rooms)
|
||||||
.flatMap((pack) => pack.getEmojis())
|
.flatMap((pack) => pack.getEmojis())
|
||||||
.forEach((emoji) => {
|
.forEach((emoji) => {
|
||||||
allEmoji.set(emoji.shortcode, emoji);
|
allEmoji.set(emoji.shortcode, emoji);
|
||||||
|
|
|
@ -67,7 +67,7 @@ class InitMatrix extends EventEmitter {
|
||||||
if (prevState === null) {
|
if (prevState === null) {
|
||||||
this.roomList = new RoomList(this.matrixClient);
|
this.roomList = new RoomList(this.matrixClient);
|
||||||
this.accountData = new AccountData(this.roomList);
|
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.notifications = new Notifications(this.roomList);
|
||||||
this.emit('init_loading_finished');
|
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
|
// 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.
|
// user has enabled it in their settings) formatting the message using markdown.
|
||||||
function formatAndEmojifyText(room, text) {
|
function formatAndEmojifyText(mx, roomList, roomId, text) {
|
||||||
const allEmoji = getShortcodeToEmoji(room);
|
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)
|
// Start by applying markdown formatting (if relevant)
|
||||||
let formattedText;
|
let formattedText;
|
||||||
|
@ -158,10 +161,11 @@ function formatAndEmojifyText(room, text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class RoomsInput extends EventEmitter {
|
class RoomsInput extends EventEmitter {
|
||||||
constructor(mx) {
|
constructor(mx, roomList) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.matrixClient = mx;
|
this.matrixClient = mx;
|
||||||
|
this.roomList = roomList;
|
||||||
this.roomIdToInput = new Map();
|
this.roomIdToInput = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +266,9 @@ class RoomsInput extends EventEmitter {
|
||||||
|
|
||||||
// Apply formatting if relevant
|
// Apply formatting if relevant
|
||||||
const formattedBody = formatAndEmojifyText(
|
const formattedBody = formatAndEmojifyText(
|
||||||
this.matrixClient.getRoom(roomId),
|
this.matrixClient,
|
||||||
|
this.roomList,
|
||||||
|
roomId,
|
||||||
input.message,
|
input.message,
|
||||||
);
|
);
|
||||||
if (formattedBody !== input.message) {
|
if (formattedBody !== input.message) {
|
||||||
|
@ -401,7 +407,9 @@ class RoomsInput extends EventEmitter {
|
||||||
|
|
||||||
// Apply formatting if relevant
|
// Apply formatting if relevant
|
||||||
const formattedBody = formatAndEmojifyText(
|
const formattedBody = formatAndEmojifyText(
|
||||||
this.matrixClient.getRoom(roomId),
|
this.matrixClient,
|
||||||
|
this.roomList,
|
||||||
|
roomId,
|
||||||
editedBody,
|
editedBody,
|
||||||
);
|
);
|
||||||
if (formattedBody !== editedBody) {
|
if (formattedBody !== editedBody) {
|
||||||
|
|
Loading…
Reference in a new issue