Skip to content

Commit e6f8d63

Browse files
committed
fix: fix toast spamming due to decky reloads
1 parent a067bf5 commit e6f8d63

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/lib/controllers/PluginController.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export class PluginController {
4747
private static steamController: SteamController;
4848

4949
private static onWakeSub: Unregisterer;
50-
50+
static isDismounted: boolean;
51+
5152
/**
5253
* Sets the plugin's serverAPI.
5354
* @param server The serverAPI to use.
@@ -131,6 +132,7 @@ export class PluginController {
131132
* Function to run when the plugin dismounts.
132133
*/
133134
static dismount(): void {
135+
this.isDismounted = true;
134136
if (this.onWakeSub) this.onWakeSub.unregister();
135137

136138
this.tabMasterManager.disposeReactions();

src/lib/controllers/PythonInterop.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FileSelectionType, ServerAPI } from "decky-frontend-lib";
22
import { validateTabs } from "../Utils";
33
import { TabProfileDictionary } from '../../state/TabProfileManager';
4+
import { PluginController } from './PluginController';
45

56
/**
67
* Class for frontend -> backend communication.
@@ -326,16 +327,17 @@ export class PythonInterop {
326327
* @param message The message of the toast.
327328
*/
328329
static toast(title: string, message: string): void {
329-
return (() => {
330+
setTimeout(() => {
331+
if (PluginController.isDismounted) return;
330332
try {
331-
return this.serverAPI.toaster.toast({
333+
this.serverAPI.toaster.toast({
332334
title: title,
333335
body: message,
334336
duration: 8000,
335337
});
336338
} catch (e) {
337339
console.log("Toaster Error", e);
338340
}
339-
})();
341+
}, 200)
340342
}
341343
}

0 commit comments

Comments
 (0)