fix: emoji-mart update breaks native emoji fetch, use SearchIndex

This commit is contained in:
Audric Ackermann 2023-08-17 10:36:50 +10:00
parent 84deed19f9
commit c60cfd8669
2 changed files with 3 additions and 4 deletions

View file

@ -102,7 +102,7 @@ export interface ConversationAttributes {
markedAsUnread: boolean; // Force the conversation as unread even if all the messages are read. Used to highlight a conversation the user wants to check again later, synced.
blocksSogsMsgReqsTimestamp: number; // if that convo is a blinded one and that user denied be contacted through sogs, this field will be set to his latest message timestamp
blocksSogsMsgReqsTimestamp: number; // if the convo is blinded and the user has denied contact through sogs, this field be set to the user's latest message timestamp
}
/**

View file

@ -1,5 +1,5 @@
import { AbortSignal } from 'abort-controller';
import { getEmojiDataFromNative } from 'emoji-mart';
import { SearchIndex } from 'emoji-mart';
import { Data } from '../../../../data/data';
import { ConversationModel } from '../../../../models/conversation';
import { Action, OpenGroupReactionResponse, Reaction } from '../../../../types/Reaction';
@ -68,9 +68,8 @@ export const sendSogsReactionOnionV4 = async (
// The SOGS endpoint supports any text input so we need to make sure we are sending a valid unicode emoji
// for an invalid input we use https://emojipedia.org/frame-with-an-x/ as a replacement since it cannot rendered as an emoji but is valid unicode
// NOTE emoji-mart v5.2.2 types for getEmojiDataFromNative are broken
// eslint-disable-next-line @typescript-eslint/await-thenable
const emoji = (await getEmojiDataFromNative(reaction.emoji)) ? reaction.emoji : '🖾';
const emoji = (await SearchIndex.search(reaction.emoji)) ? reaction.emoji : '🖾';
const endpoint = `/room/${room}/reaction/${reaction.id}/${emoji}`;
const method = reaction.action === Action.REACT ? 'PUT' : 'DELETE';
const serverPubkey = allValidRoomInfos[0].serverPublicKey;