mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 13:43:03 -04:00
Fixes For CustomUserColors
This commit is contained in:
parent
e941ba88c0
commit
7cd521cb0e
2 changed files with 34 additions and 39 deletions
|
@ -62,12 +62,8 @@ const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: {
|
|||
};
|
||||
|
||||
export function getCustomColorString(userId: string, withHash?: boolean): string | undefined {
|
||||
if (!colors[userId] || !Settings.plugins.CustomUserColors.enabled)
|
||||
return;
|
||||
|
||||
if (withHash)
|
||||
return `#${colors[userId]}`;
|
||||
|
||||
if (!colors[userId] || !Settings.plugins.CustomUserColors.enabled) return;
|
||||
if (withHash) return `#${colors[userId]}`;
|
||||
return colors[userId];
|
||||
}
|
||||
|
||||
|
@ -98,8 +94,10 @@ export default definePlugin({
|
|||
// this also affects name headers in chats outside of servers
|
||||
find: '="SYSTEM_TAG"',
|
||||
replacement: {
|
||||
match: /(?<=\.username.{0,50}?)style:/,
|
||||
replace: "style:{color:$self.colorIfServer(arguments[0])},_style:"
|
||||
// Override colorString with our custom color and disable gradients if applying the custom color.
|
||||
match: /&&null!=\i\.secondaryColor,(?<=colorString:(\i).+?(\i)=.+?)/,
|
||||
replace: (m, colorString, hasGradientColors) => `${m}` +
|
||||
`vcCustomUserColorsDummy=[${colorString},${hasGradientColors}]=$self.getMessageColorsVariables(arguments[0],${hasGradientColors}),`
|
||||
},
|
||||
predicate: () => !Settings.plugins.IrcColors.enabled
|
||||
},
|
||||
|
@ -134,21 +132,27 @@ export default definePlugin({
|
|||
},
|
||||
],
|
||||
|
||||
colorDMList(a: any): string | undefined {
|
||||
const userId = a?.user?.id;
|
||||
if (!userId) return;
|
||||
const colorString = getCustomColorString(userId, true);
|
||||
if (colorString) return colorString;
|
||||
return "inherit";
|
||||
getMessageColorsVariables(context: any, hasGradientColors: boolean) {
|
||||
const colorString = this.colorIfServer(context);
|
||||
const originalColorString = context?.author?.colorString;
|
||||
|
||||
return [colorString, hasGradientColors && colorString === originalColorString];
|
||||
},
|
||||
|
||||
colorIfServer(a: any): string | undefined {
|
||||
const roleColor = a.author?.colorString;
|
||||
colorDMList(context: any): string | undefined {
|
||||
const userId = context?.user?.id;
|
||||
const colorString = getCustomColorString(userId, true);
|
||||
return colorString ?? "inherit";
|
||||
},
|
||||
|
||||
if (a?.channel?.guild_id && !settings.store.colorInServers) return roleColor;
|
||||
colorIfServer(context: any): string | undefined {
|
||||
const userId = context?.message?.author?.id;
|
||||
const colorString = context?.author?.colorString;
|
||||
|
||||
const color = getCustomColorString(a.message.author.id, true);
|
||||
return color ?? roleColor ?? undefined;
|
||||
if (context?.channel?.guild_id && !settings.store.colorInServers) return colorString;
|
||||
|
||||
const color = getCustomColorString(userId, true);
|
||||
return color ?? colorString ?? undefined;
|
||||
},
|
||||
|
||||
colorInReplyingTo(a: any) {
|
||||
|
|
|
@ -96,19 +96,13 @@ export default definePlugin({
|
|||
const color = calculateNameColorForUser(userId);
|
||||
const customColor = userId && Settings.plugins.CustomUserColors.enabled ? getCustomColorString(userId, true) : null;
|
||||
|
||||
// Color preview in role settings
|
||||
if (context?.message?.channel_id === "1337" && userId === "313337")
|
||||
return customColor ?? colorString;
|
||||
if (
|
||||
(context?.message?.channel_id === "1337" && userId === "313337") ||
|
||||
(settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) ||
|
||||
(settings.store.applyColorOnlyToUsersWithoutColor && colorString)
|
||||
) return customColor ?? colorString;
|
||||
|
||||
if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) {
|
||||
return customColor ?? colorString;
|
||||
}
|
||||
|
||||
if (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) {
|
||||
return customColor ?? color;
|
||||
} else {
|
||||
return customColor ?? colorString;
|
||||
}
|
||||
},
|
||||
|
||||
calculateNameColorForListContext(context: any) {
|
||||
|
@ -117,14 +111,11 @@ export default definePlugin({
|
|||
const color = calculateNameColorForUser(id);
|
||||
const customColor = id && Settings.plugins.CustomUserColors.enabled ? getCustomColorString(id, true) : null;
|
||||
|
||||
if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) {
|
||||
return customColor ?? colorString;
|
||||
}
|
||||
if (
|
||||
(settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) ||
|
||||
(settings.store.applyColorOnlyToUsersWithoutColor && colorString)
|
||||
) return customColor ?? colorString;
|
||||
|
||||
if (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) {
|
||||
return customColor ?? color;
|
||||
} else {
|
||||
return customColor ?? colorString;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue