Update StickerStore & ColorPicker
Some checks failed
Test / Test (push) Has been cancelled

This commit is contained in:
thororen1234 2025-06-24 21:48:47 -04:00
parent 593ff3eb02
commit 581a19606f
No known key found for this signature in database
13 changed files with 21 additions and 47 deletions

View file

@ -7,15 +7,8 @@
import "./colorStyles.css";
import { classNameFactory } from "@api/Styles";
import { findByCodeLazy, findComponentByCodeLazy } from "@webpack";
import { Forms, useMemo } from "@webpack/common";
interface ColorPickerProps {
color: number | null;
showEyeDropper?: boolean;
onChange(value: number | null): void;
}
const ColorPicker = findComponentByCodeLazy<ColorPickerProps>(".BACKGROUND_ACCENT.css");
import { findByCodeLazy } from "@webpack";
import { ColorPicker, Forms, useMemo } from "@webpack/common";
// TinyColor is completely unmangled and it's duplicated in two modules! Fun!
const TinyColor: tinycolor.Constructor = findByCodeLazy("this._gradientType=");

View file

@ -130,4 +130,4 @@ export function ChannelTabsPreview(p) {
</Flex>
</>
);
}
}

View file

@ -99,4 +99,4 @@ export const settings = definePluginSettings({
}
});
export const CircleQuestionIcon = findComponentByCodeLazy("10.58l-3.3-3.3a1");
export const CircleQuestionIcon = findComponentByCodeLazy("10.58l-3.3-3.3a1");

View file

@ -306,4 +306,4 @@ export function useGhostTabs() {
setCount(0);
};
return new Array<JSX.Element>(count).fill(<div className={cl("tab", "ghost-tab")} />);
}
}

View file

@ -8,12 +8,9 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co
import { Devs } from "@utils/constants";
import { copyWithToast } from "@utils/misc";
import definePlugin from "@utils/types";
import { findStoreLazy } from "@webpack";
import { Menu, React } from "@webpack/common";
import { Menu, React, StickerStore } from "@webpack/common";
import { Promisable } from "type-fest";
const StickersStore = findStoreLazy("StickersStore");
interface Sticker {
t: "Sticker";
format_type: number;
@ -117,7 +114,7 @@ const expressionPickerPatch: NavContextMenuPatchCallback = (children, props: { t
if (!id) return;
if (!props.target.className?.includes("lottieCanvas")) {
const stickerCache = StickersStore.getStickerById(id);
const stickerCache = StickerStore.getStickerById(id);
if (stickerCache) {
children.push(buildMenuExpression("Sticker", () => stickerCache));
}

View file

@ -8,19 +8,10 @@ import { set } from "@api/DataStore";
import { classNameFactory } from "@api/Styles";
import { Margins } from "@utils/margins";
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot } from "@utils/modal";
import { findComponentByCodeLazy } from "@webpack";
import { Button, Forms, useState } from "@webpack/common";
import { Button, ColorPicker, Forms, useState } from "@webpack/common";
import { colors, DATASTORE_KEY } from "./index";
interface ColorPickerProps {
color: number;
showEyeDropper?: boolean;
suggestedColors?: string[];
onChange(value: number | null): void;
}
const ColorPicker = findComponentByCodeLazy<ColorPickerProps>(".BACKGROUND_ACCENT.css");
const cl = classNameFactory("vc-customColors-");
export function SetColorModal({ userId, modalProps }: { userId: string, modalProps: ModalProps; }) {

View file

@ -8,8 +8,7 @@ import { definePluginSettings, Settings } from "@api/Settings";
import { copyToClipboard } from "@utils/clipboard";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType, StartAt } from "@utils/types";
import { findComponentByCodeLazy } from "@webpack";
import { Button, Forms, TextInput, Toasts, useState } from "@webpack/common";
import { Button, ColorPicker, Forms, TextInput, Toasts, useState } from "@webpack/common";
import { darkenColorHex, generateRandomColorHex, saturateColorHex } from "./generateTheme";
import { themes } from "./themeDefinitions";
@ -86,8 +85,6 @@ function CopyPresetComponent() {
);
}
const ColorPicker = findComponentByCodeLazy(".BACKGROUND_ACCENT.css");
export function generateAndApplyProceduralTheme() {
const randomBackgroundColor = generateRandomColorHex();
@ -214,7 +211,7 @@ export function ColorPick({ propertyname }: { propertyname: string; }) {
<ColorPicker
color={parseInt(settings.store[propertyname], 16)}
onChange={color => {
const hexColor = color.toString(16).padStart(6, "0");
const hexColor = (color ?? 0).toString(16).padStart(6, "0");
settings.store[propertyname] = hexColor;
injectCSS();
}

View file

@ -8,7 +8,7 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co
import { migratePluginSettings } from "@api/Settings";
import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
import { EmojiStore, Menu, StickersStore } from "@webpack/common";
import { EmojiStore, Menu, StickerStore } from "@webpack/common";
import type { Guild } from "discord-types/general";
import { zipSync } from "fflate";
@ -30,7 +30,7 @@ async function zipGuildAssets(guild: Guild, type: "emojis" | "stickers") {
const isEmojis = type === "emojis";
const items = isEmojis
? EmojiStore.getGuilds()[guild.id]?.emojis
: StickersStore.getStickersByGuildId(guild.id);
: StickerStore.getStickersByGuildId(guild.id);
if (!items) {
return console.log("Server not found!");

View file

@ -9,7 +9,7 @@ import "./styles.css";
import { EquicordDevs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import definePlugin from "@utils/types";
import { StickersStore } from "@webpack/common";
import { StickerStore } from "@webpack/common";
import { getMimeType, isLinkAnImage, settings, stripDiscordParams } from "./settings";
@ -121,7 +121,7 @@ function loadImagePreview(url: string, sticker: boolean) {
if (sticker) {
const stickerId = url.split("/").pop()?.split(".")[0] ?? null;
const stickerData = stickerId ? StickersStore.getStickerById(stickerId) : null;
const stickerData = stickerId ? StickerStore.getStickerById(stickerId) : null;
if (stickerData) {
switch (stickerData.type) {

View file

@ -10,8 +10,7 @@
import "./colorStyles.css";
import { classNameFactory } from "@api/Styles";
import { findComponentByCodeLazy } from "@webpack";
import { Forms } from "@webpack/common";
import { ColorPicker, Forms } from "@webpack/common";
interface ColorPickerProps {
color: number | null;
@ -19,8 +18,6 @@ interface ColorPickerProps {
onChange(value: number | null): void;
}
const ColorPicker = findComponentByCodeLazy<ColorPickerProps>(".BACKGROUND_ACCENT.css");
const cl = classNameFactory("vc-remix-settings-color-");
interface Props {

View file

@ -24,12 +24,11 @@ import { Logger } from "@utils/Logger";
import { Margins } from "@utils/margins";
import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
import definePlugin from "@utils/types";
import { findByCodeLazy, findStoreLazy } from "@webpack";
import { Constants, EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common";
import { findByCodeLazy } from "@webpack";
import { Constants, EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, StickerStore, Toasts, Tooltip, UserStore } from "@webpack/common";
import { Guild } from "discord-types/general";
import { Promisable } from "type-fest";
const StickersStore = findStoreLazy("StickersStore");
const uploadEmoji = findByCodeLazy(".GUILD_EMOJIS(", "EMOJI_UPLOAD_START");
const getGuildMaxEmojiSlots = findByCodeLazy(".additionalEmojiSlots") as (guild: Guild) => number;
@ -64,7 +63,7 @@ function getUrl(data: Data) {
}
async function fetchSticker(id: string) {
const cached = StickersStore.getStickerById(id);
const cached = StickerStore.getStickerById(id);
if (cached) return cached;
const { body } = await RestAPI.get({

View file

@ -50,7 +50,7 @@ export let GuildMemberStore: Stores.GuildMemberStore & t.FluxStore;
export let RelationshipStore: t.RelationshipStore;
export let EmojiStore: t.EmojiStore;
export let StickersStore: t.StickersStore;
export let StickerStore: t.StickerStore;
export let ThemeStore: t.ThemeStore;
export let WindowStore: t.WindowStore;
export let DraftStore: t.DraftStore;
@ -83,7 +83,7 @@ waitForStore("GuildChannelStore", m => GuildChannelStore = m);
waitForStore("MessageStore", m => MessageStore = m);
waitForStore("WindowStore", m => WindowStore = m);
waitForStore("EmojiStore", m => EmojiStore = m);
waitForStore("StickersStore", m => StickersStore = m);
waitForStore("StickersStore", m => StickerStore = m);
waitForStore("TypingStore", m => TypingStore = m);
waitForStore("ThemeStore", m => {
ThemeStore = m;

View file

@ -177,7 +177,7 @@ export class EmojiStore extends FluxStore {
};
}
export class StickersStore extends FluxStore {
export class StickerStore extends FluxStore {
getStickerById(id: string): Sticker | undefined;
getStickerPack(id: string): StickerPack | undefined;
getPremiumPacks(): StickerPack[];