Fix recent emoji does not persist (#2722)
Fix recent emoji are not getting saved Refactor recent emoji retrieval to ensure structured cloning and proper type checking. The sdk was not updating account data because we are mutating the original and it compare and early return if found same.
This commit is contained in:
parent
bc6caddcc8
commit
d679e68501
1 changed files with 5 additions and 1 deletions
|
|
@ -27,7 +27,11 @@ export const getRecentEmojis = (mx: MatrixClient, limit?: number): IEmoji[] => {
|
|||
|
||||
export function addRecentEmoji(mx: MatrixClient, unicode: string) {
|
||||
const recentEmojiEvent = getAccountData(mx, AccountDataEvent.ElementRecentEmoji);
|
||||
const recentEmoji = recentEmojiEvent?.getContent<IRecentEmojiContent>().recent_emoji ?? [];
|
||||
const recentEmojiContent = recentEmojiEvent?.getContent<IRecentEmojiContent>();
|
||||
const recentEmoji =
|
||||
recentEmojiContent && Array.isArray(recentEmojiContent.recent_emoji)
|
||||
? structuredClone(recentEmojiContent.recent_emoji)
|
||||
: [];
|
||||
|
||||
const emojiIndex = recentEmoji.findIndex(([u]) => u === unicode);
|
||||
let entry: [EmojiUnicode, EmojiUsageCount];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue