diff options
author | ActuallyTheSun <78964224+ActuallyTheSun@users.noreply.github.com> | 2022-12-21 21:16:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-21 20:16:32 +0100 |
commit | d806be1346fb8218001eb86ffeaa14099248a3ab (patch) | |
tree | 8df0fd147be89daea19c5c6724177b1a1e55a4f1 /src/plugins/apiBadges.tsx | |
parent | 1f73cfa91a5a33ad73f3927ec3795a694c26922b (diff) | |
download | Vencord-d806be1346fb8218001eb86ffeaa14099248a3ab.tar.gz Vencord-d806be1346fb8218001eb86ffeaa14099248a3ab.tar.bz2 Vencord-d806be1346fb8218001eb86ffeaa14099248a3ab.zip |
feat(PlatformIndicators): add indicator to messages (#343)
Diffstat (limited to 'src/plugins/apiBadges.tsx')
-rw-r--r-- | src/plugins/apiBadges.tsx | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx index 77ea46e..72c19f3 100644 --- a/src/plugins/apiBadges.tsx +++ b/src/plugins/apiBadges.tsx @@ -66,11 +66,20 @@ export default definePlugin({ /* Patch the badge list component on user profiles */ { find: "Messages.PROFILE_USER_BADGES,role:", - replacement: { - match: /src:(\w{1,3})\[(\w{1,3})\.key\],/, - // <img src={badge.image ?? imageMap[badge.key]} {...badge.props} /> - replace: (_, imageMap, badge) => `src: ${badge}.image ?? ${imageMap}[${badge}.key], ...${badge}.props,` - } + replacement: [ + { + match: /src:(\w{1,3})\[(\w{1,3})\.key\],/, + // <img src={badge.image ?? imageMap[badge.key]} {...badge.props} /> + replace: (_, imageMap, badge) => `src: ${badge}.image ?? ${imageMap}[${badge}.key], ...${badge}.props,` + }, + { + match: /spacing:(\d{1,2}),children:(.{1,40}(.{1,2})\.jsx.+(.{1,2})\.onClick.+\)})},/, + // if the badge provides it's own component, render that instead of an image + // the badge also includes info about the user that has it (type BadgeUserArgs), which is why it's passed as props + replace: (_, s, origBadgeComponent, React, badge) => + `spacing:${s},children:${badge}.component ? () => (0,${React}.jsx)(${badge}.component, { ...${badge} }) : ${origBadgeComponent}},` + } + ] } ], |