From c890d46db7f69b45a734371b6f637e34806a51cd Mon Sep 17 00:00:00 2001 From: Federico Di Leo <38290480+FedeIlLeone@users.noreply.github.com> Date: Thu, 17 Oct 2024 21:08:51 +0200 Subject: [PATCH] fix: correct badge colors (#642) * fix: correct badge colors * chore: cleanup --- src/renderer/coremods/badges/badge.css | 6 ------ src/renderer/coremods/badges/index.tsx | 8 +++++--- .../coremods/badges/plaintextPatches.ts | 18 +----------------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/renderer/coremods/badges/badge.css b/src/renderer/coremods/badges/badge.css index cd7f55114..826d0c2c0 100644 --- a/src/renderer/coremods/badges/badge.css +++ b/src/renderer/coremods/badges/badge.css @@ -1,9 +1,3 @@ -[class*="containerWithContent"] { - min-height: -webkit-fit-content; - min-height: -moz-fit-content; - min-height: fit-content; -} - .replugged-badge { padding: 3px; box-sizing: border-box; diff --git a/src/renderer/coremods/badges/index.tsx b/src/renderer/coremods/badges/index.tsx index 36599a00d..5a7d88677 100644 --- a/src/renderer/coremods/badges/index.tsx +++ b/src/renderer/coremods/badges/index.tsx @@ -24,7 +24,6 @@ interface APIRepluggedCustomBadge { } interface APIRepluggedBadges { - [key: string]: boolean | APIRepluggedCustomBadge; developer: boolean; staff: boolean; support: boolean; @@ -152,14 +151,17 @@ export async function start(): Promise { } badgeElements.forEach((badgeElement) => { - if (badgeCache[badgeElement.id]) { + if (badgeElement.id in badgeCache) { const { component, ...props } = badgeElement; + const badgeColor = badgeCache.custom.color; newBadges.push({ ...props, icon: "replugged", component: React.createElement(component, { - color: badgeCache.custom.color ?? DISCORD_BLURPLE, + color: + (badgeColor && (badgeColor.startsWith("#") ? badgeColor : `#${badgeColor}`)) ?? + DISCORD_BLURPLE, }), }); } diff --git a/src/renderer/coremods/badges/plaintextPatches.ts b/src/renderer/coremods/badges/plaintextPatches.ts index e99849175..51c2d05d2 100644 --- a/src/renderer/coremods/badges/plaintextPatches.ts +++ b/src/renderer/coremods/badges/plaintextPatches.ts @@ -2,23 +2,7 @@ import type { PlaintextPatch } from "src/types"; export default [ { - // Edit the UserProfileBadgeList component - find: ".profileBadge2", - replacements: [ - { - // Add the "replugged-badge" class if it's our custom badge - match: /src:(\w+)\.src,className:\w+\(\)\({/, - replace: `$&["replugged-badge"]:$1.component,`, - }, - { - // Change to a div and add a children for our custom badge - match: /"img",({.+?src:(\w+)\.src,)/, - replace: `$2.component?"div":"img",$1children:$2.component,`, - }, - ], - }, - { - // Edit the ProfileBadges component (new profile design) + // Edit the ProfileBadges component find: /\.container,\w+\),"aria-label":\w+.\w+\.Messages\.PROFILE_USER_BADGES/, replacements: [ // Add the "replugged-badge" class if it's our custom badge