Skip to content

Commit

Permalink
fix: emoji-mart update breaks native emoji fetch, use SearchIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed Aug 17, 2023
1 parent 84deed1 commit c60cfd8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ts/models/conversationAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
5 changes: 2 additions & 3 deletions ts/session/apis/open_group_api/sogsv3/sogsV3SendReaction.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c60cfd8

Please sign in to comment.