Compare commits

..

3 Commits

Author SHA1 Message Date
AAGaming 93b3919325 fix reloading plugins 2024-08-08 15:26:40 -04:00
AAGaming 7a161a5b83 remove useless toast delay 2024-08-08 15:20:47 -04:00
AAGaming 1265672067 Update @decky/ui to fix non-global dfl plugins crashing the UI due to a race condition 2024-08-08 14:25:56 -04:00
6 changed files with 22 additions and 27 deletions
+1 -1
View File
@@ -47,7 +47,7 @@
}
},
"dependencies": {
"@decky/ui": "^4.7.0",
"@decky/ui": "^4.7.1",
"filesize": "^10.1.2",
"i18next": "^23.11.5",
"i18next-http-backend": "^2.5.2",
+5 -5
View File
@@ -9,8 +9,8 @@ importers:
.:
dependencies:
'@decky/ui':
specifier: ^4.7.0
version: 4.7.0
specifier: ^4.7.1
version: 4.7.1
filesize:
specifier: ^10.1.2
version: 10.1.2
@@ -215,8 +215,8 @@ packages:
'@decky/api@1.1.1':
resolution: {integrity: sha512-R5fkBRHBt5QIQY7Q0AlbVIhlIZ/nTzwBOoi8Rt4Go2fjFnoMKPInCJl6cPjXzimGwl2pyqKJgY6VnH6ar0XrHQ==}
'@decky/ui@4.7.0':
resolution: {integrity: sha512-klNWF5tnZVqzuUgFbw+pThiZjK7gKEtwbEZAo4aAuPJSVobpl/euTx9NAxY95QPCFMDgxCo6X6ioEA2nMfHfLA==}
'@decky/ui@4.7.1':
resolution: {integrity: sha512-yJwBgW+J2cMDfMkmcDFtzsubhUjekFZAtCnP55QEJ/1UKGR7sLNOvDLFYi1h5PI0K4L1XYcAMKHwbYFFTzcDTA==}
'@esbuild/aix-ppc64@0.20.2':
resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==}
@@ -2289,7 +2289,7 @@ snapshots:
'@decky/api@1.1.1': {}
'@decky/ui@4.7.0': {}
'@decky/ui@4.7.1': {}
'@esbuild/aix-ppc64@0.20.2':
optional: true
@@ -66,8 +66,6 @@ function PluginInteractables(props: { entry: ReorderableEntry<PluginTableData> }
} catch (err) {
console.error('Error Reloading Plugin Backend', err);
}
DeckyPluginLoader.importPlugin(name, version);
}}
>
{t('PluginListIndex.reload')}
+9 -6
View File
@@ -79,7 +79,7 @@ class PluginLoader extends Logger {
private reloadLock: boolean = false;
// stores a list of plugin names which requested to be reloaded
private pluginReloadQueue: { name: string; version?: string }[] = [];
private pluginReloadQueue: { name: string; version?: string; loadType: PluginLoadType }[] = [];
private loaderUpdateToast?: ToastNotification;
private pluginUpdateToast?: ToastNotification;
@@ -369,11 +369,11 @@ class PluginLoader extends Logger {
this.errorBoundaryHook.deinit();
}
public unloadPlugin(name: string) {
public unloadPlugin(name: string, skipStateUpdate: boolean = false) {
const plugin = this.plugins.find((plugin) => plugin.name === name);
plugin?.onDismount?.();
this.plugins = this.plugins.filter((p) => p !== plugin);
this.deckyState.setPlugins(this.plugins);
if (!skipStateUpdate) this.deckyState.setPlugins(this.plugins);
}
public async importPlugin(
@@ -384,7 +384,7 @@ class PluginLoader extends Logger {
) {
if (useQueue && this.reloadLock) {
this.log('Reload currently in progress, adding to queue', name);
this.pluginReloadQueue.push({ name, version: version });
this.pluginReloadQueue.push({ name, version: version, loadType });
return;
}
@@ -392,7 +392,7 @@ class PluginLoader extends Logger {
if (useQueue) this.reloadLock = true;
this.log(`Trying to load ${name}`);
this.unloadPlugin(name);
this.unloadPlugin(name, true);
const startTime = performance.now();
await this.importReactPlugin(name, version, loadType);
const endTime = performance.now();
@@ -406,7 +406,7 @@ class PluginLoader extends Logger {
this.reloadLock = false;
const nextPlugin = this.pluginReloadQueue.shift();
if (nextPlugin) {
this.importPlugin(nextPlugin.name, nextPlugin.version);
this.importPlugin(nextPlugin.name, nextPlugin.version, loadType);
}
}
}
@@ -428,6 +428,7 @@ class PluginLoader extends Logger {
...plugin,
name: name,
version: version,
loadType,
});
break;
@@ -447,6 +448,7 @@ class PluginLoader extends Logger {
...plugin,
name: name,
version: version,
loadType,
});
} else throw new Error(`${name} frontend_bundle not OK`);
break;
@@ -484,6 +486,7 @@ class PluginLoader extends Logger {
version: version,
content: <TheError />,
icon: <FaExclamationCircle />,
loadType,
});
this.toaster.toast({
title: (
+1
View File
@@ -6,6 +6,7 @@ export enum PluginLoadType {
export interface Plugin {
name: string;
version?: string;
loadType?: PluginLoadType;
icon: JSX.Element;
content?: JSX.Element;
onDismount?(): void;
+6 -13
View File
@@ -1,13 +1,5 @@
import type { ToastData, ToastNotification } from '@decky/api';
import {
ErrorBoundary,
Patch,
callOriginal,
findModuleExport,
injectFCTrampoline,
replacePatch,
sleep,
} from '@decky/ui';
import { ErrorBoundary, Patch, callOriginal, findModuleExport, injectFCTrampoline, replacePatch } from '@decky/ui';
import Toast from './components/Toast';
import Logger from './logger';
@@ -29,8 +21,6 @@ declare global {
class Toaster extends Logger {
private toastPatch?: Patch;
private markReady!: () => void;
private ready = new Promise<void>((r) => (this.markReady = r));
constructor() {
super('Toaster');
@@ -53,7 +43,6 @@ class Toaster extends Logger {
});
this.log('Initialized');
sleep(4000).then(this.markReady);
}
toast(toast: ToastData): ToastNotification {
@@ -120,7 +109,11 @@ class Toaster extends Logger {
}
}, toast.expiration);
}
this.ready.then(() => window.NotificationStore.ProcessNotification(info, toastData, ToastType.New));
try {
window.NotificationStore.ProcessNotification(info, toastData, ToastType.New);
} catch (e) {
this.error('Error while sending toast:', e);
}
return toastResult;
}