Fix CrashHandler patch
This commit is contained in:
		
							parent
							
								
									0b7c0e9587
								
							
						
					
					
						commit
						29fbe3701a
					
				
					 1 changed files with 3 additions and 10 deletions
				
			
		|  | @ -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); | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue