Add commands API (#38)

This commit is contained in:
ArjixWasTaken 2022-10-06 01:11:32 +03:00 committed by GitHub
parent a9e67aa340
commit e563521416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 267 additions and 35 deletions

View file

@ -129,23 +129,25 @@ export default ErrorBoundary.wrap(function Settings() {
value={settings.plugins[p.name].enabled || p.required || dependency}
onChange={v => {
settings.plugins[p.name].enabled = v;
let needsRestart = Boolean(p.patches?.length);
if (v) {
p.dependencies?.forEach(d => {
const dep = Plugins[d];
needsRestart ||= Boolean(dep.patches?.length && !settings.plugins[d].enabled);
settings.plugins[d].enabled = true;
if (!Plugins[d].started && !stopPlugin) {
settings.plugins[p.name].enabled = false;
if (!needsRestart && !dep.started && !startPlugin(dep)) {
showErrorToast(`Failed to start dependency ${d}. Check the console for more info.`);
}
});
if (!p.started && !startPlugin(p)) {
if (!needsRestart && !p.started && !startPlugin(p)) {
showErrorToast(`Failed to start plugin ${p.name}. Check the console for more info.`);
}
} else {
if (p.started && !stopPlugin(p)) {
if ((p.started || !p.start && p.commands?.length) && !stopPlugin(p)) {
showErrorToast(`Failed to stop plugin ${p.name}. Check the console for more info.`);
}
}
if (p.patches) changes.handleChange(p.name);
if (needsRestart) changes.handleChange(p.name);
}}
note={p.description}
tooltipNote={