Show space emoji in emojiboard

This commit is contained in:
Ajay Bura 2022-08-04 16:22:39 +05:30
parent b5788a4f58
commit b0741faa4d
3 changed files with 13 additions and 6 deletions

View file

@ -203,10 +203,15 @@ function EmojiBoard({ onSelect, searchRef }) {
return;
}
const room = initMatrix.matrixClient.getRoom(selectedRoomId);
const mx = initMatrix.matrixClient;
const room = mx.getRoom(selectedRoomId);
const parentIds = initMatrix.roomList.getAllParentSpaces(room.roomId);
const parentRooms = [...parentIds].map((id) => mx.getRoom(id));
if (room) {
const packs = getRelevantPacks(room.client, [room])
.filter((pack) => pack.getEmojis().length !== 0);
const packs = getRelevantPacks(
room.client,
[room, ...parentRooms],
).filter((pack) => pack.getEmojis().length !== 0);
// Set an index for each pack so that we know where to jump when the user uses the nav
for (let i = 0; i < packs.length; i += 1) {

View file

@ -248,9 +248,9 @@ function getShortcodeToCustomEmoji(room) {
return allEmoji;
}
function getEmojiForCompletion(room) {
function getEmojiForCompletion(mx, rooms) {
const allEmoji = new Map();
getRelevantPacks(room.client, [room])
getRelevantPacks(mx, rooms)
.flatMap((pack) => pack.getEmojis())
.forEach((emoji) => {
allEmoji.set(emoji.shortcode, emoji);

View file

@ -213,7 +213,9 @@ function RoomViewCmdBar({ roomId, roomTimeline, viewEvent }) {
setCmd({ prefix, suggestions: commands });
},
':': () => {
const emojis = getEmojiForCompletion(mx.getRoom(roomId));
const parentIds = initMatrix.roomList.getAllParentSpaces(roomId);
const parentRooms = [...parentIds].map((id) => mx.getRoom(id));
const emojis = getEmojiForCompletion(mx, [mx.getRoom(roomId), ...parentRooms]);
const recentEmoji = getRecentEmojis(20);
asyncSearch.setup(emojis, { keys: ['shortcode'], isContain: true, limit: 20 });
setCmd({