Improve component finding api and migrate plugins to use them

This commit is contained in:
Nuckyz 2023-11-22 02:49:08 -03:00
parent 371b5b0be8
commit ffe6512693
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
14 changed files with 89 additions and 57 deletions

View file

@ -22,9 +22,9 @@ import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants.js";
import { classes } from "@utils/misc";
import { Queue } from "@utils/Queue";
import { LazyComponent } from "@utils/react";
import { findComponentByCodeLazy } from "@utils/react";
import definePlugin, { OptionType } from "@utils/types";
import { find, findByCode, findByPropsLazy } from "@webpack";
import { findByPropsLazy } from "@webpack";
import {
Button,
ChannelStore,
@ -45,9 +45,9 @@ const messageCache = new Map<string, {
fetched: boolean;
}>();
const Embed = LazyComponent(() => findByCode(".inlineMediaEmbed"));
const AutoModEmbed = LazyComponent(() => findByCode(".withFooter]:", "childrenMessageContent:"));
const ChannelMessage = LazyComponent(() => find(m => m.type?.toString()?.includes("renderSimpleAccessories)")));
const Embed = findComponentByCodeLazy(".inlineMediaEmbed");
const AutoModEmbed = findComponentByCodeLazy(".withFooter]:", "childrenMessageContent:");
const ChannelMessage = findComponentByCodeLazy("renderSimpleAccessories)");
const SearchResultClasses = findByPropsLazy("message", "searchResult");