aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/index.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-11-12 15:09:02 +0100
committerVendicated <vendicated@riseup.net>2022-11-12 17:20:19 +0100
commit81edc1407071c6c0328f40a1ee487ea0388b9a7e (patch)
tree42c54ab94a58d9ffd5a2b201cfe9539a158386e4 /src/plugins/index.ts
parentb48c8d8a4a003ffe4bdee4c3ba3ae6f54ce1f317 (diff)
downloadVencord-81edc1407071c6c0328f40a1ee487ea0388b9a7e.tar.gz
Vencord-81edc1407071c6c0328f40a1ee487ea0388b9a7e.tar.bz2
Vencord-81edc1407071c6c0328f40a1ee487ea0388b9a7e.zip
fix PronounDB crash with new profile in dms, force start dependencies
Diffstat (limited to 'src/plugins/index.ts')
-rw-r--r--src/plugins/index.ts29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/plugins/index.ts b/src/plugins/index.ts
index d3842aa..268e200 100644
--- a/src/plugins/index.ts
+++ b/src/plugins/index.ts
@@ -30,11 +30,36 @@ export const PMLogger = logger;
export const plugins = Plugins;
export const patches = [] as Patch[];
+const settings = Settings.plugins;
+
export function isPluginEnabled(p: string) {
- return (Settings.plugins[p]?.enabled || Plugins[p]?.required) ?? false;
+ return (
+ Plugins[p]?.required ||
+ Plugins[p]?.isDependency ||
+ settings[p]?.enabled
+ ) ?? false;
+}
+
+const pluginsValues = Object.values(Plugins);
+
+// First roundtrip to mark and force enable dependencies
+for (const p of pluginsValues) {
+ p.dependencies?.forEach(d => {
+ const dep = Plugins[d];
+ if (dep) {
+ settings[d].enabled = true;
+ dep.isDependency = true;
+ }
+ else {
+ const error = new Error(`Plugin ${p.name} has unresolved dependency ${d}`);
+ if (IS_DEV)
+ throw error;
+ logger.warn(error);
+ }
+ });
}
-for (const p of Object.values(Plugins))
+for (const p of pluginsValues)
if (p.patches && isPluginEnabled(p.name)) {
for (const patch of p.patches) {
patch.plugin = p.name;