diff options
Diffstat (limited to 'src/plugins/crashHandler.ts')
-rw-r--r-- | src/plugins/crashHandler.ts | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/plugins/crashHandler.ts b/src/plugins/crashHandler.ts index e35dfed..6457e09 100644 --- a/src/plugins/crashHandler.ts +++ b/src/plugins/crashHandler.ts @@ -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" }); |