Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.

Commit

Permalink
fix ED plugin settings not saving (due to BD fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
joe27g committed Oct 19, 2020
1 parent 3f26e91 commit d038d39
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions dom_shit.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const c = {
};

// config util
window.ED = { plugins: {}, version: '2.8' };
window.ED = { plugins: {}, version: '2.8.1' };
Object.defineProperty(ED, 'config', {
get: function() {
let conf;
Expand Down Expand Up @@ -326,14 +326,22 @@ window.EDApi = window.BdApi = class EDApi {
}

static loadData(pluginName, key) {
if (!ED.plugins[pluginName]) return null;
return this.loadPluginSettings(pluginName)[key];
const pl = ED.plugins[pluginName] || Object.values(ED.plugins).find(p => p.name === pluginName);
if (!pl) return null;
const id = pl.id;

if (!ED.plugins[id]) return null;
return this.loadPluginSettings(id)[key];
}

static saveData(pluginName, key, data) {
const obj = this.loadPluginSettings(pluginName);
const pl = ED.plugins[pluginName] || Object.values(ED.plugins).find(p => p.name === pluginName);
if (!pl) return null;
const id = pl.id;

const obj = this.loadPluginSettings(id);
obj[key] = data;
return this.savePluginSettings(pluginName, obj);
return this.savePluginSettings(id, obj);
}

static getData(pluginName, key) {
Expand Down Expand Up @@ -570,22 +578,3 @@ window.BdApi.Themes = new class AddonAPI {
get() {return null;}
getAll() {return [];}
};

window.BdApi.loadData = function(pluginName, key) {
const pl = Object.values(ED.plugins).find(p => p.name === pluginName);
if (!pl) return null;
const id = pl.id;

if (!ED.plugins[id]) return null;
return this.loadPluginSettings(id)[key];
};

window.BdApi.saveData = function(pluginName, key, data) {
const pl = Object.values(ED.plugins).find(p => p.name === pluginName);
if (!pl) return null;
const id = pl.id;

const obj = this.loadPluginSettings(id);
obj[key] = data;
return this.savePluginSettings(id, obj);
};

0 comments on commit d038d39

Please sign in to comment.