From 29fbe3701a906685ab1e7da07c9a4e155efa98d6 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 2 Sep 2023 03:03:31 -0300 Subject: [PATCH] Fix CrashHandler patch --- src/plugins/crashHandler.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/plugins/crashHandler.ts b/src/plugins/crashHandler.ts index f15fb8e9e..a1ba01c3d 100644 --- a/src/plugins/crashHandler.ts +++ b/src/plugins/crashHandler.ts @@ -23,10 +23,12 @@ import { Logger } from "@utils/Logger"; import { closeAllModals } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; import { maybePromptToUpdate } from "@utils/updater"; +import { findByPropsLazy } from "@webpack"; import { FluxDispatcher, NavigationRouter } from "@webpack/common"; import type { ReactElement } from "react"; const CrashHandlerLogger = new Logger("CrashHandler"); +const ModalStack = findByPropsLazy("pushLazy", "popAll"); const settings = definePluginSettings({ attemptToPreventCrashes: { @@ -51,8 +53,6 @@ export default definePlugin({ authors: [Devs.Nuckyz], enabledByDefault: true, - popAllModals: undefined as (() => void) | undefined, - settings, patches: [ @@ -62,13 +62,6 @@ export default definePlugin({ match: /(?=this\.setState\()/, replace: "$self.handleCrash(this)||" } - }, - { - find: 'dispatch({type:"MODAL_POP_ALL"})', - replacement: { - match: /"MODAL_POP_ALL".+?};(?<=(\i)=function.+?)/, - replace: (m, popAll) => `${m}$self.popAllModals=${popAll};` - } } ], @@ -128,7 +121,7 @@ export default definePlugin({ CrashHandlerLogger.debug("Failed to close open context menu.", err); } try { - this.popAllModals?.(); + ModalStack?.popAll(); } catch (err) { CrashHandlerLogger.debug("Failed to close old modals.", err); }