From c93e74ec0ca1719155a491d7466c033924733525 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:14:28 -0500 Subject: [PATCH] Revert "CustomUserColors: Use Usernames Now (Fix DM Colors)" This reverts commit 054e2a020883db0aa8e4ce5fbed5b108779c1be1. --- .../customUserColors/SetColorModal.tsx | 8 +++--- .../customUserColors/index.tsx | 28 ++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/equicordplugins/customUserColors/SetColorModal.tsx b/src/equicordplugins/customUserColors/SetColorModal.tsx index 830d1e22..bdb36d6a 100644 --- a/src/equicordplugins/customUserColors/SetColorModal.tsx +++ b/src/equicordplugins/customUserColors/SetColorModal.tsx @@ -23,8 +23,8 @@ const ColorPicker = findComponentByCodeLazy("#{intl::USER_SETT const cl = classNameFactory("vc-customColors-"); -export function SetColorModal({ username, modalProps }: { username: string, modalProps: ModalProps; }) { - const initialColor = parseInt(colors[username], 16) || 372735; +export function SetColorModal({ userId, modalProps }: { userId: string, modalProps: ModalProps; }) { + const initialColor = parseInt(colors[userId], 16) || 372735; // color picker default to current color set for user (if null it's 0x05afff :3 ) const [colorPickerColor, setColorPickerColor] = useState(initialColor); @@ -41,13 +41,13 @@ export function SetColorModal({ username, modalProps }: { username: string, moda } async function saveUserColor() { - colors[username] = colorPickerColor.toString(16).padStart(6, "0"); + colors[userId] = colorPickerColor.toString(16).padStart(6, "0"); await set(DATASTORE_KEY, colors); modalProps.onClose(); } async function deleteUserColor() { - delete colors[username]; + delete colors[userId]; await set(DATASTORE_KEY, colors); modalProps.onClose(); } diff --git a/src/equicordplugins/customUserColors/index.tsx b/src/equicordplugins/customUserColors/index.tsx index 0db522ae..1136829d 100644 --- a/src/equicordplugins/customUserColors/index.tsx +++ b/src/equicordplugins/customUserColors/index.tsx @@ -29,7 +29,7 @@ export let colors: Record = {}; const requireSettingsMenu = extractAndLoadChunksLazy(['name:"UserSettings"'], /createPromise:.{0,20}(\i\.\i\("?.+?"?\).*?).then\(\i\.bind\(\i,"?(.+?)"?\)\).{0,50}"UserSettings"/); const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: { user: User; }) => { - if (user?.username == null) return; + if (user?.id == null) return; const setCustomColorItem = ( { await requireSettingsMenu(); - openModal(modalProps => ); + openModal(modalProps => ); }} /> ); @@ -46,14 +46,14 @@ const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: { }; -export function getCustomColorString(username: string, withHash?: boolean): string | undefined { - if (!colors[username] || !Settings.plugins.CustomUserColors.enabled) +export function getCustomColorString(userId: string, withHash?: boolean): string | undefined { + if (!colors[userId] || !Settings.plugins.CustomUserColors.enabled) return; if (withHash) - return `#${colors[username]}`; + return `#${colors[userId]}`; - return colors[username]; + return colors[userId]; } const settings = definePluginSettings({ @@ -94,20 +94,16 @@ export default definePlugin({ predicate: () => settings.store.dmList, find: "!1,wrapContent", replacement: { - match: /(?<=\}=(\i).*?nameAndDecorators,)/, - replace: "style:{color:$self.colorDMList($1)}," + match: /(nameAndDecorators,)/, + replace: "$1style:{color:$self.colorDMList(arguments[0])}," }, }, ], colorDMList(a: any): string | undefined { - const username = - typeof a?.name?.props?.children === "string" - ? a.name.props.children - : a?.name?.props?.children?.props?.children?.[0] - ?? null; - if (!username) return; - const colorString = getCustomColorString(username, true); + const userId = a?.subText?.props?.user?.id; + if (!userId) return; + const colorString = getCustomColorString(userId, true); if (colorString) return colorString; return "inherit"; }, @@ -117,7 +113,7 @@ export default definePlugin({ if (a?.channel?.guild_id && !settings.store.colorInServers) return roleColor; - const color = getCustomColorString(a.message.author.username, true); + const color = getCustomColorString(a.message.author.id, true); return color ?? roleColor ?? undefined; } });