fix IrcColors
This commit is contained in:
parent
0444831073
commit
7779e5a1ec
1 changed files with 34 additions and 16 deletions
|
|
@ -67,9 +67,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: /&&null!=\i\.secondaryColor,(?<=colorString:(\i).+?(\i)=.+?)/,
|
match: /(?<=colorString:\i,colorStrings:\i,colorRoleName:\i}=)(\i),/,
|
||||||
replace: (m, colorString, hasGradientColors) => `${m}` +
|
replace: "$self.wrapMessageColorProps($1, arguments[0]),"
|
||||||
`vcIrcColorsDummy=[${colorString},${hasGradientColors}]=$self.getMessageColorsVariables(arguments[0],${hasGradientColors}),`
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -82,11 +81,26 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
getMessageColorsVariables(context: any, hasGradientColors: boolean) {
|
wrapMessageColorProps(colorProps: { colorString: string, colorStrings?: Record<"primaryColor" | "secondaryColor" | "tertiaryColor", string>; }, context: any) {
|
||||||
|
try {
|
||||||
const colorString = this.calculateNameColorForMessageContext(context);
|
const colorString = this.calculateNameColorForMessageContext(context);
|
||||||
const originalColorString = context?.author?.colorString;
|
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;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
calculateNameColorForMessageContext(context: any) {
|
calculateNameColorForMessageContext(context: any) {
|
||||||
|
|
@ -108,6 +122,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
calculateNameColorForListContext(context: any) {
|
calculateNameColorForListContext(context: any) {
|
||||||
|
try {
|
||||||
const id = context?.user?.id;
|
const id = context?.user?.id;
|
||||||
const colorString = context?.colorString;
|
const colorString = context?.colorString;
|
||||||
const color = calculateNameColorForUser(id);
|
const color = calculateNameColorForUser(id);
|
||||||
|
|
@ -119,5 +134,8 @@ export default definePlugin({
|
||||||
return (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString)
|
return (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString)
|
||||||
? color
|
? color
|
||||||
: colorString;
|
: colorString;
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to calculate name color for list context:", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue