use findBulk on CrashHandler and cleaups
This commit is contained in:
parent
9945219de7
commit
8ef1882d43
|
@ -23,15 +23,26 @@ import { Logger } from "@utils/Logger";
|
||||||
import { closeAllModals } from "@utils/modal";
|
import { closeAllModals } from "@utils/modal";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { maybePromptToUpdate } from "@utils/updater";
|
import { maybePromptToUpdate } from "@utils/updater";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { filters, findBulk, proxyLazyWebpack } from "@webpack";
|
||||||
import { FluxDispatcher, NavigationRouter, SelectedChannelStore } from "@webpack/common";
|
import { FluxDispatcher, NavigationRouter, SelectedChannelStore } from "@webpack/common";
|
||||||
import type { ReactElement } from "react";
|
import type { ReactElement } from "react";
|
||||||
|
|
||||||
const CrashHandlerLogger = new Logger("CrashHandler");
|
const CrashHandlerLogger = new Logger("CrashHandler");
|
||||||
const ModalStack = findByPropsLazy("pushLazy", "popAll");
|
const { ModalStack, DraftManager, DraftType, closeExpressionPicker } = proxyLazyWebpack(() => {
|
||||||
const DraftManager = findByPropsLazy("clearDraft", "saveDraft");
|
const modules = findBulk(
|
||||||
const { DraftType } = findByPropsLazy("DraftType");
|
filters.byProps("pushLazy", "popAll"),
|
||||||
const { closeExpressionPicker } = findByPropsLazy("closeExpressionPicker", "openExpressionPicker");
|
filters.byProps("clearDraft", "saveDraft"),
|
||||||
|
filters.byProps("DraftType"),
|
||||||
|
filters.byProps("closeExpressionPicker", "openExpressionPicker"),
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
ModalStack: modules[0],
|
||||||
|
DraftManager: modules[1],
|
||||||
|
DraftType: modules[2]?.DraftType,
|
||||||
|
closeExpressionPicker: modules[3]?.closeExpressionPicker,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
attemptToPreventCrashes: {
|
attemptToPreventCrashes: {
|
||||||
|
@ -138,7 +149,7 @@ export default definePlugin({
|
||||||
CrashHandlerLogger.debug("Failed to close open context menu.", err);
|
CrashHandlerLogger.debug("Failed to close open context menu.", err);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ModalStack?.popAll();
|
ModalStack.popAll();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
CrashHandlerLogger.debug("Failed to close old modals.", err);
|
CrashHandlerLogger.debug("Failed to close old modals.", err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,15 +35,13 @@ interface UserPermission {
|
||||||
|
|
||||||
type UserPermissions = Array<UserPermission>;
|
type UserPermissions = Array<UserPermission>;
|
||||||
|
|
||||||
const Classes = proxyLazyWebpack(() => {
|
const Classes = proxyLazyWebpack(() =>
|
||||||
const modules = findBulk(
|
Object.assign({}, ...findBulk(
|
||||||
filters.byProps("roles", "rolePill", "rolePillBorder"),
|
filters.byProps("roles", "rolePill", "rolePillBorder"),
|
||||||
filters.byProps("roleCircle", "dotBorderBase", "dotBorderColor"),
|
filters.byProps("roleCircle", "dotBorderBase", "dotBorderColor"),
|
||||||
filters.byProps("roleNameOverflow", "root", "roleName", "roleRemoveButton")
|
filters.byProps("roleNameOverflow", "root", "roleName", "roleRemoveButton")
|
||||||
);
|
))
|
||||||
|
) as Record<"roles" | "rolePill" | "rolePillBorder" | "desaturateUserColors" | "flex" | "alignCenter" | "justifyCenter" | "svg" | "background" | "dot" | "dotBorderColor" | "roleCircle" | "dotBorderBase" | "flex" | "alignCenter" | "justifyCenter" | "wrap" | "root" | "role" | "roleRemoveButton" | "roleDot" | "roleFlowerStar" | "roleRemoveIcon" | "roleRemoveIconFocused" | "roleVerifiedIcon" | "roleName" | "roleNameOverflow" | "actionButton" | "overflowButton" | "addButton" | "addButtonIcon" | "overflowRolesPopout" | "overflowRolesPopoutArrowWrapper" | "overflowRolesPopoutArrow" | "popoutBottom" | "popoutTop" | "overflowRolesPopoutHeader" | "overflowRolesPopoutHeaderIcon" | "overflowRolesPopoutHeaderText" | "roleIcon", string>;
|
||||||
return Object.assign({}, ...modules);
|
|
||||||
}) as Record<"roles" | "rolePill" | "rolePillBorder" | "desaturateUserColors" | "flex" | "alignCenter" | "justifyCenter" | "svg" | "background" | "dot" | "dotBorderColor" | "roleCircle" | "dotBorderBase" | "flex" | "alignCenter" | "justifyCenter" | "wrap" | "root" | "role" | "roleRemoveButton" | "roleDot" | "roleFlowerStar" | "roleRemoveIcon" | "roleRemoveIconFocused" | "roleVerifiedIcon" | "roleName" | "roleNameOverflow" | "actionButton" | "overflowButton" | "addButton" | "addButtonIcon" | "overflowRolesPopout" | "overflowRolesPopoutArrowWrapper" | "overflowRolesPopoutArrow" | "popoutBottom" | "popoutTop" | "overflowRolesPopoutHeader" | "overflowRolesPopoutHeaderIcon" | "overflowRolesPopoutHeaderText" | "roleIcon", string>;
|
|
||||||
|
|
||||||
function UserPermissionsComponent({ guild, guildMember, showBorder }: { guild: Guild; guildMember: GuildMember; showBorder: boolean; }) {
|
function UserPermissionsComponent({ guild, guildMember, showBorder }: { guild: Guild; guildMember: GuildMember; showBorder: boolean; }) {
|
||||||
const stns = settings.use(["permissionsSortOrder"]);
|
const stns = settings.use(["permissionsSortOrder"]);
|
||||||
|
|
Loading…
Reference in a new issue