Fixes and ShowHiddenChannels improvements (#634)

~ Fixes #630
~ Fixes #618
This commit is contained in:
Nuckyz 2023-03-21 03:07:16 -03:00 committed by GitHub
parent d482d33d6f
commit 586b26d2d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 147 additions and 47 deletions

View file

@ -42,6 +42,7 @@ const settings = definePluginSettings({
});
let crashCount: number = 0;
let lastCrashTimestamp: number = 0;
export default definePlugin({
name: "CrashHandler",
@ -80,6 +81,7 @@ export default definePlugin({
});
} catch { }
lastCrashTimestamp = Date.now();
return false;
}
@ -97,17 +99,21 @@ export default definePlugin({
} catch (err) {
CrashHandlerLogger.error("Failed to handle crash", err);
return false;
} finally {
lastCrashTimestamp = Date.now();
}
},
handlePreventCrash(_this: ReactElement & { forceUpdate: () => void; }) {
try {
showNotification({
color: "#eed202",
title: "Discord has crashed!",
body: "Attempting to recover...",
});
} catch { }
if (Date.now() - lastCrashTimestamp >= 1_000) {
try {
showNotification({
color: "#eed202",
title: "Discord has crashed!",
body: "Attempting to recover...",
});
} catch { }
}
try {
FluxDispatcher.dispatch({ type: "CONTEXT_MENU_CLOSE" });