mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-29 00:14:23 -04:00
Fix CustomUserColors
This commit is contained in:
parent
0741086dc2
commit
ee16f4b8d8
1 changed files with 24 additions and 8 deletions
|
@ -61,7 +61,7 @@ const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getCustomColorString(userId: string, withHash?: boolean): string | undefined {
|
export function getCustomColorString(userId: string | undefined, withHash?: boolean): string | undefined {
|
||||||
if (!userId) return;
|
if (!userId) return;
|
||||||
if (!colors[userId] || !Settings.plugins.CustomUserColors.enabled) return;
|
if (!colors[userId] || !Settings.plugins.CustomUserColors.enabled) return;
|
||||||
if (withHash) return `#${colors[userId]}`;
|
if (withHash) return `#${colors[userId]}`;
|
||||||
|
@ -96,9 +96,8 @@ export default definePlugin({
|
||||||
find: '="SYSTEM_TAG"',
|
find: '="SYSTEM_TAG"',
|
||||||
replacement: {
|
replacement: {
|
||||||
// Override colorString with our custom color and disable gradients if applying the custom color.
|
// Override colorString with our custom color and disable gradients if applying the custom color.
|
||||||
match: /useContext\(\i\.\i\),(?<=colorString:(\i).+?(\i)=.+?)/,
|
match: /(?<=colorString:\i,colorStrings:\i,colorRoleName:\i}=)(\i),/,
|
||||||
replace: (m, colorString, hasGradientColors) => `${m}` +
|
replace: "$self.wrapMessageColorProps($1, arguments[0]),"
|
||||||
`vcCustomUserColorsDummy=[${colorString},${hasGradientColors}]=$self.getMessageColorsVariables(arguments[0],${hasGradientColors}),`
|
|
||||||
},
|
},
|
||||||
predicate: () => !Settings.plugins.IrcColors.enabled
|
predicate: () => !Settings.plugins.IrcColors.enabled
|
||||||
},
|
},
|
||||||
|
@ -133,11 +132,26 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
getMessageColorsVariables(context: any, hasGradientColors: boolean) {
|
wrapMessageColorProps(colorProps: { colorString: string, colorStrings?: Record<"primaryColor" | "secondaryColor" | "tertiaryColor", string>; }, context: any) {
|
||||||
const colorString = this.colorIfServer(context);
|
try {
|
||||||
const originalColorString = context?.author?.colorString;
|
const colorString = this.colorIfServer(context);
|
||||||
|
if (colorString === colorProps.colorString) {
|
||||||
|
return colorProps;
|
||||||
|
}
|
||||||
|
|
||||||
return [colorString, hasGradientColors && colorString === originalColorString];
|
return {
|
||||||
|
...colorProps,
|
||||||
|
colorString,
|
||||||
|
colorStrings: colorProps.colorStrings && {
|
||||||
|
primaryColor: colorString,
|
||||||
|
secondaryColor: undefined,
|
||||||
|
tertiaryColor: undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to calculate message color strings:", e);
|
||||||
|
return colorProps;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
colorDMList(context: any): string | undefined {
|
colorDMList(context: any): string | undefined {
|
||||||
|
@ -150,6 +164,8 @@ export default definePlugin({
|
||||||
const userId = context?.message?.author?.id;
|
const userId = context?.message?.author?.id;
|
||||||
const colorString = context?.author?.colorString;
|
const colorString = context?.author?.colorString;
|
||||||
|
|
||||||
|
if (context?.message?.channel_id === "1337" && userId === "313337") return colorString;
|
||||||
|
|
||||||
if (context?.channel?.guild_id && !settings.store.colorInServers) return colorString;
|
if (context?.channel?.guild_id && !settings.store.colorInServers) return colorString;
|
||||||
|
|
||||||
const color = getCustomColorString(userId, true);
|
const color = getCustomColorString(userId, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue