SMYN: Fix mention color for default role color. (#832)

This commit is contained in:
Etorix 2026-02-23 19:39:57 -08:00 • committed by GitHub
parent 16d0b089a0
commit 69ad255cba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,7 +20,7 @@ import { classNameFactory, ModalCloseButton, ModalContent, ModalFooter, ModalHea
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { GuildMember, Message, User } from "@vencord/discord-types"; import { GuildMember, Message, User } from "@vencord/discord-types";
import { findByCodeLazy, findStoreLazy } from "@webpack"; import { findByCodeLazy, findStoreLazy } from "@webpack";
import { ChannelStore, GuildMemberStore, GuildStore, Menu, MessageStore, RelationshipStore, StreamerModeStore, TextInput, useEffect, useState } from "@webpack/common"; import { ChannelStore, GuildMemberStore, GuildRoleStore, GuildStore, Menu, MessageStore, RelationshipStore, StreamerModeStore, TextInput, useEffect, useState } from "@webpack/common";
import { JSX } from "react"; import { JSX } from "react";
const SMYNC = classNameFactory(); const SMYNC = classNameFactory();
@ -480,7 +480,9 @@ function renderUsername(
const ircColorsEnabled = isPluginEnabled(ircColors.name); const ircColorsEnabled = isPluginEnabled(ircColors.name);
const authorColorStrings = colorStrings || (author as any)?.colorStrings || null; const authorTopRole = (author as GuildMember)?.guildId && (author as any)?.highestRoleId;
const authorTopRoleColor = authorTopRole && GuildRoleStore.getRole((author as GuildMember).guildId, authorTopRole)?.colorStrings;
const authorColorStrings = colorStrings || (author as any)?.colorStrings || authorTopRoleColor || null;
const authorDisplayNameStyles = (!inGuild && !ircColorsEnabled && (author as any)?.displayNameStyles) || null; const authorDisplayNameStyles = (!inGuild && !ircColorsEnabled && (author as any)?.displayNameStyles) || null;
const effectType = authorDisplayNameStyles ? getEffectType(authorDisplayNameStyles.effectId) : null; const effectType = authorDisplayNameStyles ? getEffectType(authorDisplayNameStyles.effectId) : null;
const effectCSSVars = authorDisplayNameStyles ? computeEffectCSSVars(authorDisplayNameStyles) : {}; const effectCSSVars = authorDisplayNameStyles ? computeEffectCSSVars(authorDisplayNameStyles) : {};
@ -490,9 +492,9 @@ function renderUsername(
const shouldAnimateEffect = shouldShowEffect && !AccessibilityStore.useReducedMotion; const shouldAnimateEffect = shouldShowEffect && !AccessibilityStore.useReducedMotion;
const canUseGradient = ((author as GuildMember)?.guildId ? (GuildStore.getGuild((author as GuildMember).guildId) ?? {}).premiumFeatures?.features.includes("ENHANCED_ROLE_COLORS") : !inGuild); const canUseGradient = ((author as GuildMember)?.guildId ? (GuildStore.getGuild((author as GuildMember).guildId) ?? {}).premiumFeatures?.features.includes("ENHANCED_ROLE_COLORS") : !inGuild);
const useTopRoleStyle = isMention || isReactionsPopout || channel?.isDM() || channel?.isGroupDM(); const useTopStyle = isMention || isReactionsPopout || channel?.isDM() || channel?.isGroupDM();
const topRoleStyle = author ? resolveColor(authorColorStrings, authorDisplayNameStyles, "Role", canUseGradient, inGuild, ircColorsEnabled, isHovering) : null; const topStyle = author ? resolveColor(authorColorStrings, authorDisplayNameStyles, "Role", canUseGradient, inGuild, ircColorsEnabled, isHovering) : null;
const hasGradient = !!topRoleStyle?.gradient && Object.keys(topRoleStyle.gradient).length > 0; const hasGradient = !!topStyle?.gradient && Object.keys(topStyle.gradient).length > 0;
const textMutedValue = getComputedStyle(document.documentElement)?.getPropertyValue("--text-muted")?.trim() || "#72767d"; const textMutedValue = getComputedStyle(document.documentElement)?.getPropertyValue("--text-muted")?.trim() || "#72767d";
const options = splitTemplate(includedNames); const options = splitTemplate(includedNames);
@ -647,7 +649,7 @@ function renderUsername(
// Only mentions and reactions popouts should patch in the gradient glow or else a double glow will appear on messages. // Only mentions and reactions popouts should patch in the gradient glow or else a double glow will appear on messages.
const hoveringClass = (isHovering ? " smyn-gradient-hovered" : ""); const hoveringClass = (isHovering ? " smyn-gradient-hovered" : "");
const gradientClasses = useTopRoleStyle const gradientClasses = useTopStyle
? "smyn-gradient smyn-gradient-inherit-bg" + hoveringClass ? "smyn-gradient smyn-gradient-inherit-bg" + hoveringClass
: "smyn-gradient smyn-gradient-unset-bg" + hoveringClass; : "smyn-gradient smyn-gradient-unset-bg" + hoveringClass;
@ -679,7 +681,7 @@ function renderUsername(
<span <span
style={{ style={{
...topLevelStyle, ...topLevelStyle,
...(topRoleStyle?.normal.original || {}) ...(topStyle?.normal.original || {})
}} }}
className="smyn-container" className="smyn-container"
> >
@ -688,7 +690,7 @@ function renderUsername(
<span <span
className={SMYNC(firstGroupClasses, { [gradientClasses]: shouldGradientGlow })} className={SMYNC(firstGroupClasses, { [gradientClasses]: shouldGradientGlow })}
data-text={shouldGradientGlow ? firstDataText : undefined} data-text={shouldGradientGlow ? firstDataText : undefined}
style={(shouldGradientGlow && useTopRoleStyle && topRoleStyle ? topRoleStyle.gradient.animated : undefined) as React.CSSProperties} style={(shouldGradientGlow && useTopStyle && topStyle ? topStyle.gradient.animated : undefined) as React.CSSProperties}
> >
<span <span
className={SMYNC(firstNameClasses, { className={SMYNC(firstNameClasses, {
@ -699,12 +701,12 @@ function renderUsername(
data-username-with-effects={needsEffectDataAttr && shouldShowEffect ? first.name : undefined} data-username-with-effects={needsEffectDataAttr && shouldShowEffect ? first.name : undefined}
style={shouldShowEffect style={shouldShowEffect
? undefined ? undefined
: topRoleStyle ? : topStyle ?
shouldAnimateGradients && topRoleStyle.gradient shouldAnimateGradients && topStyle.gradient
? topRoleStyle.gradient.animated ? topStyle.gradient.animated
: topRoleStyle.gradient : topStyle.gradient
? topRoleStyle.gradient.static.original ? topStyle.gradient.static.original
: topRoleStyle.normal.original : topStyle.normal.original
: undefined : undefined
}> }>
{first.wrapped}</span> {first.wrapped}</span>