mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-18 22:28:51 -05:00
IrcColors: Fix causing react errors sometimes
This commit is contained in:
parent
414539f45e
commit
1eff1a02bd
1 changed files with 3 additions and 9 deletions
|
@ -23,11 +23,11 @@ import definePlugin, { OptionType } from "@utils/types";
|
|||
import { useMemo } from "@webpack/common";
|
||||
|
||||
// Calculate a CSS color string based on the user ID
|
||||
function calculateNameColorForUser(id: string) {
|
||||
function calculateNameColorForUser(id?: string) {
|
||||
const { lightness } = settings.use(["lightness"]);
|
||||
const idHash = useMemo(() => h64(id), [id]);
|
||||
const idHash = useMemo(() => id ? h64(id) : null, [id]);
|
||||
|
||||
return `hsl(${idHash % 360n}, 100%, ${lightness}%)`;
|
||||
return idHash && `hsl(${idHash % 360n}, 100%, ${lightness}%)`;
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
|
@ -70,16 +70,10 @@ export default definePlugin({
|
|||
|
||||
calculateNameColorForMessageContext(context: any) {
|
||||
const id = context?.message?.author?.id;
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return calculateNameColorForUser(id);
|
||||
},
|
||||
calculateNameColorForListContext(context: any) {
|
||||
const id = context?.user?.id;
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return calculateNameColorForUser(id);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue