CR 0.1.8 Crash fix

This commit is contained in:
_Lighty_ 2020-10-05 20:22:16 +02:00 committed by GitHub
parent fb3f3c5b5b
commit d9c2fe6ba4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 8 deletions

View File

@ -1,4 +1,7 @@
# [CrashRecovery](https://1lighty.github.io/BetterDiscordStuff/?plugin=CrashRecovery "CrashRecovery") Changelog
### 0.1.8
- Crash fix.
### 0.1.7
- Changed to module.exports because useless backwards incompatbile changes are the motto for BBD apparently.

View File

@ -41,7 +41,7 @@ module.exports = (() => {
twitter_username: ''
}
],
version: '0.1.7',
version: '0.1.8',
description: 'In the event that your Discord crashes, the plugin enables you to get Discord back to a working state, without needing to reload at all.',
github: 'https://github.com/1Lighty',
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/CrashRecovery/CrashRecovery.plugin.js'
@ -50,7 +50,7 @@ module.exports = (() => {
{
title: 'fixed',
type: 'fixed',
items: ['Changed to module.exports because useless backwards incompatbile changes are the motto for BBD apparently.']
items: ['Crash fix.']
}
],
defaultConfig: [
@ -72,6 +72,8 @@ module.exports = (() => {
const DelayedCall = (WebpackModules.getByProps('DelayedCall') || {}).DelayedCall;
const ElectronDiscordModule = WebpackModules.getByProps('cleanupDisplaySleep') || { cleanupDisplaySleep: DiscordModules.DiscordConstants.NOOP };
const ModalStack = WebpackModules.getByProps('openModal');
return class CrashRecovery extends Plugin {
constructor() {
super();
@ -166,12 +168,36 @@ module.exports = (() => {
cleanupDiscord() {
ElectronDiscordModule.cleanupDisplaySleep();
Dispatcher.wait(() => {
DiscordModules.ContextMenuActions.closeContextMenu();
DiscordModules.ModalStack.popAll();
DiscordModules.LayerManager.popAllLayers();
DiscordModules.PopoutStack.closeAll();
WebpackModules.getByProps('openModal').modalsApi.setState(() => ({ default: [] })); /* slow? unsafe? async? */
if (!this.settings.useThirdStep) DiscordModules.NavigationUtils.transitionTo('/channels/@me');
try {
DiscordModules.ContextMenuActions.closeContextMenu();
} catch (err) {
Logger.stacktrace('Failed to close all context menus', err);
}
try {
DiscordModules.ModalStack.popAll();
} catch (err) {
Logger.stacktrace('Failed to pop old modalstack', err);
}
try {
DiscordModules.LayerManager.popAllLayers();
} catch (err) {
Logger.stacktrace('Failed to pop all layers', err);
}
try {
DiscordModules.PopoutStack.closeAll();
} catch (err) {
Logger.stacktrace('Failed to close all popouts', err);
}
try {
(ModalStack.modalsApi || ModalStack.useModalsStore).setState(() => ({ default: [] })); /* slow? unsafe? async? */
} catch (err) {
Logger.stacktrace('Failed to pop new modalstack');
}
try {
if (!this.settings.useThirdStep) DiscordModules.NavigationUtils.transitionTo('/channels/@me');
} catch (err) {
Logger.stacktrace('Failed to transition to home');
}
});
}