From 80b493d7a863831e7770463f03d56048ae9bdced Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 17 Jul 2024 21:30:10 +0200 Subject: [PATCH] WhoReacted: fix errors --- src/plugins/messageLinkEmbeds/index.tsx | 1 + src/plugins/whoReacted/index.tsx | 32 +++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/plugins/messageLinkEmbeds/index.tsx b/src/plugins/messageLinkEmbeds/index.tsx index cf180d0d..9fd67738 100644 --- a/src/plugins/messageLinkEmbeds/index.tsx +++ b/src/plugins/messageLinkEmbeds/index.tsx @@ -147,6 +147,7 @@ async function fetchMessage(channelID: string, messageID: string) { if (!msg) return; const message: Message = MessageStore.getMessages(msg.channel_id).receiveMessage(msg).get(msg.id); + if (!message) return; messageCache.set(message.id, { message, diff --git a/src/plugins/whoReacted/index.tsx b/src/plugins/whoReacted/index.tsx index 5721dc91..679fe714 100644 --- a/src/plugins/whoReacted/index.tsx +++ b/src/plugins/whoReacted/index.tsx @@ -43,14 +43,23 @@ function fetchReactions(msg: Message, emoji: ReactionEmoji, type: number) { }, oldFormErrors: true }) - .then(res => FluxDispatcher.dispatch({ - type: "MESSAGE_REACTION_ADD_USERS", - channelId: msg.channel_id, - messageId: msg.id, - users: res.body, - emoji, - reactionType: type - })) + .then(res => { + for (const user of res.body) { + FluxDispatcher.dispatch({ + type: "USER_UPDATE", + user + }); + } + + FluxDispatcher.dispatch({ + type: "MESSAGE_REACTION_ADD_USERS", + channelId: msg.channel_id, + messageId: msg.id, + users: res.body, + emoji, + reactionType: type + }); + }) .catch(console.error) .finally(() => sleep(250)); } @@ -148,13 +157,6 @@ export default definePlugin({ const reactions = getReactionsWithQueue(message, emoji, type); const users = Object.values(reactions).filter(Boolean) as User[]; - for (const user of users) { - FluxDispatcher.dispatch({ - type: "USER_UPDATE", - user - }); - } - return (