mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 23:32:00 +00:00
fix onDismount
This commit is contained in:
@@ -4,7 +4,6 @@ import { FaPlug } from 'react-icons/fa';
|
|||||||
import { DeckyState, DeckyStateContextProvider } from './components/DeckyState';
|
import { DeckyState, DeckyStateContextProvider } from './components/DeckyState';
|
||||||
import LegacyPlugin from './components/LegacyPlugin';
|
import LegacyPlugin from './components/LegacyPlugin';
|
||||||
import PluginView from './components/PluginView';
|
import PluginView from './components/PluginView';
|
||||||
import StorePage from './components/store/Store';
|
|
||||||
import TitleView from './components/TitleView';
|
import TitleView from './components/TitleView';
|
||||||
import Logger from './logger';
|
import Logger from './logger';
|
||||||
import { Plugin } from './plugin';
|
import { Plugin } from './plugin';
|
||||||
@@ -22,10 +21,6 @@ class PluginLoader extends Logger {
|
|||||||
private routerHook: RouterHook = new RouterHook();
|
private routerHook: RouterHook = new RouterHook();
|
||||||
private deckyState: DeckyState = new DeckyState();
|
private deckyState: DeckyState = new DeckyState();
|
||||||
|
|
||||||
private reloadLock: boolean = false;
|
|
||||||
// stores a list of plugin names which requested to be reloaded
|
|
||||||
private pluginReloadQueue: string[] = [];
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(PluginLoader.name);
|
super(PluginLoader.name);
|
||||||
this.log('Initialized');
|
this.log('Initialized');
|
||||||
@@ -44,8 +39,6 @@ class PluginLoader extends Logger {
|
|||||||
),
|
),
|
||||||
icon: <FaPlug />,
|
icon: <FaPlug />,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.routerHook.addRoute('/decky/store', () => <StorePage />);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public addPluginInstallPrompt(artifact: string, version: string, request_id: string) {
|
public addPluginInstallPrompt(artifact: string, version: string, request_id: string) {
|
||||||
@@ -74,18 +67,7 @@ class PluginLoader extends Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public deinit() {
|
|
||||||
this.routerHook.removeRoute('/decky/store');
|
|
||||||
}
|
|
||||||
|
|
||||||
public async importPlugin(name: string) {
|
public async importPlugin(name: string) {
|
||||||
try {
|
|
||||||
if (this.reloadLock) {
|
|
||||||
this.log('Reload currently in progress, adding to queue', name);
|
|
||||||
this.pluginReloadQueue.push(name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log(`Trying to load ${name}`);
|
this.log(`Trying to load ${name}`);
|
||||||
let find = this.plugins.find((x) => x.name == name);
|
let find = this.plugins.find((x) => x.name == name);
|
||||||
if (find) this.plugins.splice(this.plugins.indexOf(find), 1);
|
if (find) this.plugins.splice(this.plugins.indexOf(find), 1);
|
||||||
@@ -97,15 +79,6 @@ class PluginLoader extends Logger {
|
|||||||
this.log(`Loaded ${name}`);
|
this.log(`Loaded ${name}`);
|
||||||
|
|
||||||
this.deckyState.setPlugins(this.plugins);
|
this.deckyState.setPlugins(this.plugins);
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
this.reloadLock = false;
|
|
||||||
const nextPlugin = this.pluginReloadQueue.shift();
|
|
||||||
if (nextPlugin) {
|
|
||||||
this.importPlugin(nextPlugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async importReactPlugin(name: string) {
|
private async importReactPlugin(name: string) {
|
||||||
@@ -114,8 +87,7 @@ class PluginLoader extends Logger {
|
|||||||
let content = await eval(await res.text())(this.createPluginAPI(name));
|
let content = await eval(await res.text())(this.createPluginAPI(name));
|
||||||
this.plugins.push({
|
this.plugins.push({
|
||||||
name: name,
|
name: name,
|
||||||
icon: content.icon,
|
...content,
|
||||||
content: content.content,
|
|
||||||
});
|
});
|
||||||
} else throw new Error(`${name} frontend_bundle not OK`);
|
} else throw new Error(`${name} frontend_bundle not OK`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user