BetterSettings: fix patch
This commit is contained in:
parent
b16133d122
commit
f284f82a74
1 changed files with 11 additions and 6 deletions
|
|
@ -11,7 +11,7 @@ import { Devs } from "@utils/constants";
|
|||
import { classNameFactory } from "@utils/css";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { waitFor } from "@webpack";
|
||||
import { findCssClassesLazy } from "@webpack";
|
||||
import { ComponentDispatch, FocusLock, Menu, useEffect, useRef } from "@webpack/common";
|
||||
import type { HTMLAttributes, ReactElement } from "react";
|
||||
|
||||
|
|
@ -20,8 +20,7 @@ import fullHeightStyle from "./fullHeightContext.css?managed";
|
|||
type SettingsEntry = { section: string, label: string; };
|
||||
|
||||
const cl = classNameFactory("");
|
||||
let Classes: Record<string, string>;
|
||||
waitFor(["animating", "baseLayer", "bg", "layer", "layers"], m => Classes = m);
|
||||
const Classes = findCssClassesLazy("animating", "baseLayer", "bg", "layer", "layers");
|
||||
|
||||
const settings = definePluginSettings({
|
||||
disableFade: {
|
||||
|
|
@ -140,8 +139,8 @@ export default definePlugin({
|
|||
find: "#{intl::USER_SETTINGS_ACTIONS_MENU_LABEL}",
|
||||
replacement: [
|
||||
{
|
||||
match: /=\[\];if\((\i)(?=\.forEach.{0,100}"logout"!==\i.{0,30}(\i)\.get\(\i\))/,
|
||||
replace: "=$self.wrapMap([]);if($self.transformSettingsEntries($1,$2)",
|
||||
match: /=\[\];(\i)(?=\.forEach.{0,100}"logout"!==\i.{0,30}(\i)\.get\(\i\))/,
|
||||
replace: "=$self.wrapMap([]);$self.transformSettingsEntries($1,$2)",
|
||||
predicate: () => settings.store.organizeMenu
|
||||
},
|
||||
{
|
||||
|
|
@ -161,7 +160,13 @@ export default definePlugin({
|
|||
// Thus, we sanity check webpack modules
|
||||
Layer(props: LayerProps) {
|
||||
try {
|
||||
[FocusLock.$$vencordGetWrappedComponent(), ComponentDispatch, Classes].forEach(e => e.test);
|
||||
// findCssClassesLazy returns an empty object if the classes aren't found
|
||||
// so we have to explicitly test for the presence of classes
|
||||
if (!Classes.layer?.length) {
|
||||
new Logger("BetterSettings").error("Failed to find classes");
|
||||
return props.children;
|
||||
}
|
||||
[FocusLock.$$vencordGetWrappedComponent(), ComponentDispatch].forEach(e => e.test);
|
||||
} catch {
|
||||
new Logger("BetterSettings").error("Failed to find some components");
|
||||
return props.children;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue