diff options
author | TheKodeToad <TheKodeToad@proton.me> | 2023-10-03 01:26:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-03 02:26:38 +0200 |
commit | 1f38a8eeab3b2b184a779298928ffdccb03b0715 (patch) | |
tree | 5e03ed21d1f0e656bcbc46162d491cef0ba15e9a /src/plugins | |
parent | 6db9721c067bac510ea480067029f8c3c0d09d98 (diff) | |
download | Vencord-1f38a8eeab3b2b184a779298928ffdccb03b0715.tar.gz Vencord-1f38a8eeab3b2b184a779298928ffdccb03b0715.tar.bz2 Vencord-1f38a8eeab3b2b184a779298928ffdccb03b0715.zip |
Fix WhoReacted (#1769)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/whoReacted/README.md | 5 | ||||
-rw-r--r-- | src/plugins/whoReacted/index.tsx | 119 |
2 files changed, 26 insertions, 98 deletions
diff --git a/src/plugins/whoReacted/README.md b/src/plugins/whoReacted/README.md new file mode 100644 index 0000000..ee4227a --- /dev/null +++ b/src/plugins/whoReacted/README.md @@ -0,0 +1,5 @@ +# WhoReacted + +Next to each reaction, display each user's avatar. Each avatar can be clicked and will open the profile. + +![](https://github.com/Vendicated/Vencord/assets/57493648/97fec9e8-396f-4f5e-916e-1ec21445113d) diff --git a/src/plugins/whoReacted/index.tsx b/src/plugins/whoReacted/index.tsx index 0bdb5c2..a4e74f9 100644 --- a/src/plugins/whoReacted/index.tsx +++ b/src/plugins/whoReacted/index.tsx @@ -24,14 +24,14 @@ import { LazyComponent, useForceUpdater } from "@utils/react"; import definePlugin from "@utils/types"; import { findByCode, findByPropsLazy } from "@webpack"; import { ChannelStore, FluxDispatcher, React, RestAPI, Tooltip } from "@webpack/common"; -import { ReactionEmoji, User } from "discord-types/general"; +import { CustomEmoji } from "@webpack/types"; +import { Message, ReactionEmoji, User } from "discord-types/general"; const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers")); const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar"); -const ReactionStore = findByPropsLazy("getReactions"); - const queue = new Queue(); +let reactions: Record<string, ReactionCacheEntry>; function fetchReactions(msg: Message, emoji: ReactionEmoji, type: number) { const key = emoji.name + (emoji.id ? `:${emoji.id}` : ""); @@ -57,11 +57,9 @@ function fetchReactions(msg: Message, emoji: ReactionEmoji, type: number) { 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: {} }; + const cache = reactions[key] ??= { fetched: false, users: {} }; if (!cache.fetched) { - queue.unshift(() => - fetchReactions(msg, e, type) - ); + queue.unshift(() => fetchReactions(msg, e, type)); cache.fetched = true; } @@ -92,7 +90,7 @@ function handleClickAvatar(event: React.MouseEvent<HTMLElement, MouseEvent>) { export default definePlugin({ name: "WhoReacted", - description: "Renders the Avatars of reactors", + description: "Renders the avatars of users who reacted to a message", authors: [Devs.Ven, Devs.KannaDev], patches: [{ @@ -101,6 +99,12 @@ export default definePlugin({ match: /(?<=(\i)=(\i)\.hideCount,)(.+?reactionCount.+?\}\))/, replace: (_, hideCount, props, rest) => `whoReactedProps=${props},${rest},${hideCount}?null:$self.renderUsers(whoReactedProps)` } + }, { + find: '.displayName="MessageReactionsStore";', + replacement: { + match: /(?<=CONNECTION_OPEN:function\(\){)(\i)={}/, + replace: "$&;$self.reactions=$1" + } }], renderUsers(props: RootObject) { @@ -150,106 +154,25 @@ export default definePlugin({ </div> </div> ); + }, + + set reactions(value: any) { + reactions = value; } }); - -export interface GuildMemberAvatar { } - -export interface Author { - id: string; - username: string; - discriminator: string; - avatar: string; - avatarDecoration?: any; - email: string; - verified: boolean; - bot: boolean; - system: boolean; - mfaEnabled: boolean; - mobile: boolean; - desktop: boolean; - premiumType: number; - flags: number; - publicFlags: number; - purchasedFlags: number; - premiumUsageFlags: number; - phone: string; - nsfwAllowed: boolean; - guildMemberAvatars: GuildMemberAvatar; -} - -export interface Emoji { - id: string; - name: string; -} - -export interface Reaction { - emoji: Emoji; - count: number; - burst_user_ids: any[]; - burst_count: number; - burst_colors: any[]; - burst_me: boolean; - me: boolean; -} - -export interface Message { - id: string; - type: number; - channel_id: string; - author: Author; - content: string; - deleted: boolean; - editHistory: any[]; - attachments: any[]; - embeds: any[]; - mentions: any[]; - mentionRoles: any[]; - mentionChannels: any[]; - mentioned: boolean; - pinned: boolean; - mentionEveryone: boolean; - tts: boolean; - codedLinks: any[]; - giftCodes: any[]; - timestamp: string; - editedTimestamp?: any; - state: string; - nonce?: any; - blocked: boolean; - call?: any; - bot: boolean; - webhookId?: any; - reactions: Reaction[]; - applicationId?: any; - application?: any; - activity?: any; - messageReference?: any; - flags: number; - isSearchHit: boolean; - stickers: any[]; - stickerItems: any[]; - components: any[]; - loggingName?: any; - interaction?: any; - interactionData?: any; - interactionError?: any; -} - -export interface Emoji { - id: string; - name: string; - animated: boolean; +interface ReactionCacheEntry { + fetched: boolean; + users: Record<string, User>; } -export interface RootObject { +interface RootObject { message: Message; readOnly: boolean; isLurking: boolean; isPendingMember: boolean; useChatFontScaling: boolean; - emoji: Emoji; + emoji: CustomEmoji; count: number; burst_user_ids: any[]; burst_count: number; |