Simplify some components finds; Make undo of patch groups more clear
This commit is contained in:
parent
6573c4757c
commit
1b179f3c6d
3 changed files with 6 additions and 14 deletions
|
@ -20,17 +20,12 @@ import { definePluginSettings, Settings } from "@api/Settings";
|
|||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { find, findStoreLazy, LazyComponentWebpack } from "@webpack";
|
||||
import { findExportedComponentLazy, findStoreLazy } from "@webpack";
|
||||
import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
|
||||
|
||||
import { buildSeveralUsers } from "../typingTweaks";
|
||||
|
||||
const ThreeDots = LazyComponentWebpack(() => {
|
||||
// This doesn't really need to explicitly find Dots' own module, but it's fine
|
||||
const res = find(m => m.Dots && !m.Menu);
|
||||
|
||||
return res?.Dots;
|
||||
});
|
||||
const ThreeDots = findExportedComponentLazy("Dots", "AnimatedDots");
|
||||
|
||||
const TypingStore = findStoreLazy("TypingStore");
|
||||
const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore");
|
||||
|
|
|
@ -23,14 +23,11 @@ import { Settings } from "@api/Settings";
|
|||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { filters, find, LazyComponentWebpack } from "@webpack";
|
||||
import { findExportedComponentLazy } from "@webpack";
|
||||
import { Menu, Popout, useState } from "@webpack/common";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
const HeaderBarIcon = LazyComponentWebpack(() => {
|
||||
const filter = filters.byCode(".HEADER_BAR_BADGE");
|
||||
return find(m => m.Icon && filter(m.Icon))?.Icon;
|
||||
});
|
||||
const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider");
|
||||
|
||||
function VencordPopout(onClose: () => void) {
|
||||
const pluginEntries = [] as ReactNode[];
|
||||
|
|
|
@ -212,7 +212,7 @@ function patchFactories(factories: Record<string | number, (module: { exports: a
|
|||
}
|
||||
|
||||
if (patch.group) {
|
||||
logger.warn(`Undoing patch ${patch.find} by ${patch.plugin} because replacement ${replacement.match} had no effect`);
|
||||
logger.warn(`Undoing patch group ${patch.find} by ${patch.plugin} because replacement ${replacement.match} had no effect`);
|
||||
code = previousCode;
|
||||
mod = previousMod;
|
||||
patchedBy.delete(patch.plugin);
|
||||
|
@ -260,7 +260,7 @@ function patchFactories(factories: Record<string | number, (module: { exports: a
|
|||
|
||||
patchedBy.delete(patch.plugin);
|
||||
if (patch.group) {
|
||||
logger.warn(`Undoing patch ${patch.find} by ${patch.plugin} because replacement ${replacement.match} errored`);
|
||||
logger.warn(`Undoing patch group ${patch.find} by ${patch.plugin} because replacement ${replacement.match} errored`);
|
||||
code = previousCode;
|
||||
mod = previousMod;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue