working, but cursed

This commit is contained in:
sadan 2024-11-25 19:41:46 -05:00
parent 6e3eb3cc4e
commit 53273b83ba
No known key found for this signature in database

View file

@ -21,9 +21,10 @@ import ErrorBoundary from "@components/ErrorBoundary";
import { makeRange } from "@components/PluginSettings/components";
import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import { useForceUpdater } from "@utils/react";
import definePlugin, { OptionType } from "@utils/types";
import { findByCodeLazy } from "@webpack";
import { ChannelStore, GuildMemberStore, GuildStore, useEffect, useState } from "@webpack/common";
import { ChannelStore, GuildMemberStore, GuildStore, useEffect, useMemo, useState } from "@webpack/common";
import { Color, Contrast } from "./color";
@ -106,7 +107,7 @@ export function useGetContrastValue() {
}
export default definePlugin({
name: "RoleColorEverywhere",
authors: [Devs.KingFish, Devs.lewisakura, Devs.AutumnVN, Devs.Kyuuhachi, Devs.jamesbt365],
authors: [Devs.KingFish, Devs.lewisakura, Devs.AutumnVN, Devs.Kyuuhachi, Devs.jamesbt365, Devs.sadan],
description: "Adds the top role color anywhere possible",
settings,
@ -236,11 +237,12 @@ export default definePlugin({
},
useMessageColorsStyle(message: any, ref: any | null) {
try {
const { messageSaturation } = settings.use(["messageSaturation"]);
const author = useMessageAuthor(message);
const contrast = useGetContrastValue();
const [dep, update] = useForceUpdater(true);
return useMemo(() => {
try {
if (author.colorString != null && messageSaturation !== 0) {
if (contrast === 1) {
const value = `color-mix(in oklab, ${author.colorString} ${messageSaturation}%, var({DEFAULT}))`;
@ -251,7 +253,8 @@ export default definePlugin({
"--text-muted": value.replace("{DEFAULT}", "--text-muted")
};
}
if (!ref.current) return;
// why
if (!ref.current) setTimeout(update, 0);
const computed = window.getComputedStyle(ref.current);
const textNormal = computed.getPropertyValue("--text-normal"),
headerPrimary = computed.getPropertyValue("--header-primary"),
@ -273,6 +276,7 @@ export default definePlugin({
}
return null;
}, [author, contrast, ref, messageSaturation, dep]);
},
RoleGroupColor: ErrorBoundary.wrap(({ id, count, title, guildId, label }: { id: string; count: number; title: string; guildId: string; label: string; }) => {