From 2489bc68315f4e2c7cd54eae7c64846d6d1218d9 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 12 Feb 2023 14:58:44 -0300 Subject: [PATCH] Fix WhoReacted (#487) Co-authored-by: Ven --- src/plugins/whoReacted.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/whoReacted.tsx b/src/plugins/whoReacted.tsx index a14ca3a2..a260bac0 100644 --- a/src/plugins/whoReacted.tsx +++ b/src/plugins/whoReacted.tsx @@ -32,12 +32,13 @@ const ReactionStore = findByPropsLazy("getReactions"); const queue = new Queue(); -function fetchReactions(msg: Message, emoji: ReactionEmoji) { +function fetchReactions(msg: Message, emoji: ReactionEmoji, type: number) { const key = emoji.name + (emoji.id ? `:${emoji.id}` : ""); return RestAPI.get({ url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${key}`, query: { - limit: 100 + limit: 100, + type }, oldFormErrors: true }) @@ -46,18 +47,19 @@ function fetchReactions(msg: Message, emoji: ReactionEmoji) { channelId: msg.channel_id, messageId: msg.id, users: res.body, - emoji + emoji, + reactionType: type })) .catch(console.error) .finally(() => sleep(250)); } -function getReactionsWithQueue(msg: Message, e: ReactionEmoji) { - const key = `${msg.id}:${e.name}:${e.id ?? ""}`; +function getReactionsWithQueue(msg: Message, e: ReactionEmoji, type: number) { + const key = `${msg.id}:${e.name}:${e.id ?? ""}:${type}`; const cache = ReactionStore.__getLocalVars().reactions[key] ??= { fetched: false, users: {} }; if (!cache.fetched) { queue.unshift(() => - fetchReactions(msg, e) + fetchReactions(msg, e, type) ); cache.fetched = true; } @@ -104,7 +106,7 @@ export default definePlugin({ ); }, - _renderUsers({ message, emoji }: RootObject) { + _renderUsers({ message, emoji, type }: RootObject) { const forceUpdate = useForceUpdater(); React.useEffect(() => { const cb = (e: any) => { @@ -116,7 +118,7 @@ export default definePlugin({ return () => FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD_USERS", cb); }, [message.id]); - const reactions = getReactionsWithQueue(message, emoji); + const reactions = getReactionsWithQueue(message, emoji, type); const users = Object.values(reactions).filter(Boolean) as User[]; return (