mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 22:12:03 +00:00
fix reloading plugins
This commit is contained in:
@@ -66,8 +66,6 @@ function PluginInteractables(props: { entry: ReorderableEntry<PluginTableData> }
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error Reloading Plugin Backend', err);
|
console.error('Error Reloading Plugin Backend', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckyPluginLoader.importPlugin(name, version);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('PluginListIndex.reload')}
|
{t('PluginListIndex.reload')}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class PluginLoader extends Logger {
|
|||||||
|
|
||||||
private reloadLock: boolean = false;
|
private reloadLock: boolean = false;
|
||||||
// stores a list of plugin names which requested to be reloaded
|
// 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 loaderUpdateToast?: ToastNotification;
|
||||||
private pluginUpdateToast?: ToastNotification;
|
private pluginUpdateToast?: ToastNotification;
|
||||||
@@ -369,11 +369,11 @@ class PluginLoader extends Logger {
|
|||||||
this.errorBoundaryHook.deinit();
|
this.errorBoundaryHook.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public unloadPlugin(name: string) {
|
public unloadPlugin(name: string, skipStateUpdate: boolean = false) {
|
||||||
const plugin = this.plugins.find((plugin) => plugin.name === name);
|
const plugin = this.plugins.find((plugin) => plugin.name === name);
|
||||||
plugin?.onDismount?.();
|
plugin?.onDismount?.();
|
||||||
this.plugins = this.plugins.filter((p) => p !== plugin);
|
this.plugins = this.plugins.filter((p) => p !== plugin);
|
||||||
this.deckyState.setPlugins(this.plugins);
|
if (!skipStateUpdate) this.deckyState.setPlugins(this.plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async importPlugin(
|
public async importPlugin(
|
||||||
@@ -384,7 +384,7 @@ class PluginLoader extends Logger {
|
|||||||
) {
|
) {
|
||||||
if (useQueue && this.reloadLock) {
|
if (useQueue && this.reloadLock) {
|
||||||
this.log('Reload currently in progress, adding to queue', name);
|
this.log('Reload currently in progress, adding to queue', name);
|
||||||
this.pluginReloadQueue.push({ name, version: version });
|
this.pluginReloadQueue.push({ name, version: version, loadType });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ class PluginLoader extends Logger {
|
|||||||
if (useQueue) this.reloadLock = true;
|
if (useQueue) this.reloadLock = true;
|
||||||
this.log(`Trying to load ${name}`);
|
this.log(`Trying to load ${name}`);
|
||||||
|
|
||||||
this.unloadPlugin(name);
|
this.unloadPlugin(name, true);
|
||||||
const startTime = performance.now();
|
const startTime = performance.now();
|
||||||
await this.importReactPlugin(name, version, loadType);
|
await this.importReactPlugin(name, version, loadType);
|
||||||
const endTime = performance.now();
|
const endTime = performance.now();
|
||||||
@@ -406,7 +406,7 @@ class PluginLoader extends Logger {
|
|||||||
this.reloadLock = false;
|
this.reloadLock = false;
|
||||||
const nextPlugin = this.pluginReloadQueue.shift();
|
const nextPlugin = this.pluginReloadQueue.shift();
|
||||||
if (nextPlugin) {
|
if (nextPlugin) {
|
||||||
this.importPlugin(nextPlugin.name, nextPlugin.version);
|
this.importPlugin(nextPlugin.name, nextPlugin.version, loadType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,6 +428,7 @@ class PluginLoader extends Logger {
|
|||||||
...plugin,
|
...plugin,
|
||||||
name: name,
|
name: name,
|
||||||
version: version,
|
version: version,
|
||||||
|
loadType,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -447,6 +448,7 @@ class PluginLoader extends Logger {
|
|||||||
...plugin,
|
...plugin,
|
||||||
name: name,
|
name: name,
|
||||||
version: version,
|
version: version,
|
||||||
|
loadType,
|
||||||
});
|
});
|
||||||
} else throw new Error(`${name} frontend_bundle not OK`);
|
} else throw new Error(`${name} frontend_bundle not OK`);
|
||||||
break;
|
break;
|
||||||
@@ -484,6 +486,7 @@ class PluginLoader extends Logger {
|
|||||||
version: version,
|
version: version,
|
||||||
content: <TheError />,
|
content: <TheError />,
|
||||||
icon: <FaExclamationCircle />,
|
icon: <FaExclamationCircle />,
|
||||||
|
loadType,
|
||||||
});
|
});
|
||||||
this.toaster.toast({
|
this.toaster.toast({
|
||||||
title: (
|
title: (
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export enum PluginLoadType {
|
|||||||
export interface Plugin {
|
export interface Plugin {
|
||||||
name: string;
|
name: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
|
loadType?: PluginLoadType;
|
||||||
icon: JSX.Element;
|
icon: JSX.Element;
|
||||||
content?: JSX.Element;
|
content?: JSX.Element;
|
||||||
onDismount?(): void;
|
onDismount?(): void;
|
||||||
|
|||||||
Reference in New Issue
Block a user