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 {
|
export function getCustomColorString(userId: string, withHash?: boolean): string | undefined {
|
||||||
if (!colors[userId] || !Settings.plugins.CustomUserColors.enabled)
|
if (!colors[userId] || !Settings.plugins.CustomUserColors.enabled) return;
|
||||||
return;
|
if (withHash) return `#${colors[userId]}`;
|
||||||
|
|
||||||
if (withHash)
|
|
||||||
return `#${colors[userId]}`;
|
|
||||||
|
|
||||||
return colors[userId];
|
return colors[userId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +94,10 @@ export default definePlugin({
|
||||||
// this also affects name headers in chats outside of servers
|
// this also affects name headers in chats outside of servers
|
||||||
find: '="SYSTEM_TAG"',
|
find: '="SYSTEM_TAG"',
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=\.username.{0,50}?)style:/,
|
// Override colorString with our custom color and disable gradients if applying the custom color.
|
||||||
replace: "style:{color:$self.colorIfServer(arguments[0])},_style:"
|
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
|
predicate: () => !Settings.plugins.IrcColors.enabled
|
||||||
},
|
},
|
||||||
|
@ -134,21 +132,27 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
colorDMList(a: any): string | undefined {
|
getMessageColorsVariables(context: any, hasGradientColors: boolean) {
|
||||||
const userId = a?.user?.id;
|
const colorString = this.colorIfServer(context);
|
||||||
if (!userId) return;
|
const originalColorString = context?.author?.colorString;
|
||||||
const colorString = getCustomColorString(userId, true);
|
|
||||||
if (colorString) return colorString;
|
return [colorString, hasGradientColors && colorString === originalColorString];
|
||||||
return "inherit";
|
|
||||||
},
|
},
|
||||||
|
|
||||||
colorIfServer(a: any): string | undefined {
|
colorDMList(context: any): string | undefined {
|
||||||
const roleColor = a.author?.colorString;
|
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);
|
if (context?.channel?.guild_id && !settings.store.colorInServers) return colorString;
|
||||||
return color ?? roleColor ?? undefined;
|
|
||||||
|
const color = getCustomColorString(userId, true);
|
||||||
|
return color ?? colorString ?? undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
colorInReplyingTo(a: any) {
|
colorInReplyingTo(a: any) {
|
||||||
|
|
|
@ -96,19 +96,13 @@ export default definePlugin({
|
||||||
const color = calculateNameColorForUser(userId);
|
const color = calculateNameColorForUser(userId);
|
||||||
const customColor = userId && Settings.plugins.CustomUserColors.enabled ? getCustomColorString(userId, true) : null;
|
const customColor = userId && Settings.plugins.CustomUserColors.enabled ? getCustomColorString(userId, true) : null;
|
||||||
|
|
||||||
// Color preview in role settings
|
if (
|
||||||
if (context?.message?.channel_id === "1337" && userId === "313337")
|
(context?.message?.channel_id === "1337" && userId === "313337") ||
|
||||||
return customColor ?? colorString;
|
(settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) ||
|
||||||
|
(settings.store.applyColorOnlyToUsersWithoutColor && colorString)
|
||||||
|
) return customColor ?? colorString;
|
||||||
|
|
||||||
if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) {
|
return customColor ?? color;
|
||||||
return customColor ?? colorString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) {
|
|
||||||
return customColor ?? color;
|
|
||||||
} else {
|
|
||||||
return customColor ?? colorString;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
calculateNameColorForListContext(context: any) {
|
calculateNameColorForListContext(context: any) {
|
||||||
|
@ -117,14 +111,11 @@ export default definePlugin({
|
||||||
const color = calculateNameColorForUser(id);
|
const color = calculateNameColorForUser(id);
|
||||||
const customColor = id && Settings.plugins.CustomUserColors.enabled ? getCustomColorString(id, true) : null;
|
const customColor = id && Settings.plugins.CustomUserColors.enabled ? getCustomColorString(id, true) : null;
|
||||||
|
|
||||||
if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) {
|
if (
|
||||||
return customColor ?? colorString;
|
(settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) ||
|
||||||
}
|
(settings.store.applyColorOnlyToUsersWithoutColor && colorString)
|
||||||
|
) return customColor ?? colorString;
|
||||||
|
|
||||||
if (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) {
|
return customColor ?? color;
|
||||||
return customColor ?? color;
|
|
||||||
} else {
|
|
||||||
return customColor ?? colorString;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue