fix blanks and button

This commit is contained in:
Zack Rauen 2020-03-30 13:05:57 -04:00
parent 78e961e7fc
commit 49c6db3bd2
5 changed files with 15 additions and 34 deletions

File diff suppressed because one or more lines are too long

2
js/main.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -5,10 +5,7 @@ import BDEvents from "./bdEvents";
import Utils from "./utils"; import Utils from "./utils";
function PluginModule() { function PluginModule() {
this.getString = function(value) {
if (!value) return "???";
return typeof value == "string" ? value : value.toString();
};
} }
PluginModule.prototype.loadPlugins = function () { PluginModule.prototype.loadPlugins = function () {
@ -22,18 +19,6 @@ PluginModule.prototype.loadPlugins = function () {
plugin = bdplugins[plugins[i]].plugin; plugin = bdplugins[plugins[i]].plugin;
name = plugin.getName(); name = plugin.getName();
if (plugin.load && typeof(plugin.load) == "function") plugin.load(); if (plugin.load && typeof(plugin.load) == "function") plugin.load();
let meta = bdplugins[plugins[i]];
// Because DiscordCrypt is freezing bd globals they shouldn't be accessing.
if (Object.isFrozen(meta)) {
meta = Object.assign({}, meta);
delete bdplugins[plugins[i]];
bdplugins[plugins[i]] = meta;
}
meta.name = this.getString(plugin.getName());
meta.author = this.getString(plugin.getAuthor());
meta.description = this.getString(plugin.getDescription());
meta.version = this.getString(plugin.getVersion());
} }
catch (err) { catch (err) {
pluginCookie[name] = false; pluginCookie[name] = false;

View File

@ -6,10 +6,7 @@ import Utils from "./utils";
import DOM from "./domtools"; import DOM from "./domtools";
function ThemeModule() { function ThemeModule() {
this.getString = function(value) {
if (!value) return "???";
return typeof value == "string" ? value : value.toString();
};
} }
ThemeModule.prototype.loadThemes = function () { ThemeModule.prototype.loadThemes = function () {
@ -19,10 +16,6 @@ ThemeModule.prototype.loadThemes = function () {
for (let i = 0; i < themes.length; i++) { for (let i = 0; i < themes.length; i++) {
const theme = bdthemes[themes[i]]; const theme = bdthemes[themes[i]];
theme.name = this.getString(theme.name);
theme.author = this.getString(theme.author);
theme.description = this.getString(theme.description);
theme.version = this.getString(theme.version);
if (!themeCookie[theme.name]) themeCookie[theme.name] = false; if (!themeCookie[theme.name]) themeCookie[theme.name] = false;
if (themeCookie[theme.name]) DOM.addStyle(DOM.escapeID(theme.id), unescape(theme.css)); if (themeCookie[theme.name]) DOM.addStyle(DOM.escapeID(theme.id), unescape(theme.css));
} }

View File

@ -20,7 +20,7 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
this.onChange = this.onChange.bind(this); this.onChange = this.onChange.bind(this);
this.showSettings = this.showSettings.bind(this); this.showSettings = this.showSettings.bind(this);
this.setInitialState(); this.setInitialState();
this.hasSettings = this.props.addon.plugin && typeof this.props.addon.plugin.getSettingsPanel === "function"; this.hasSettings = this.props.addon.plugin && typeof(this.props.addon.plugin.getSettingsPanel) === "function";
this.settingsPanel = ""; this.settingsPanel = "";
this.edit = this.edit.bind(this); this.edit = this.edit.bind(this);
@ -88,7 +88,7 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
get settingsComponent() { get settingsComponent() {
const name = this.getString(this.props.addon.name); const name = this.getString(this.props.addon.name);
try { this.settingsPanel = this.props.addon.plugin.getSettingsPanel(); } try { this.settingsPanel = this.props.addon.getSettingsPanel(); }
catch (err) { Utils.err("Plugins", "Unable to get settings panel for " + this.props.addon.name + ".", err); } catch (err) { Utils.err("Plugins", "Unable to get settings panel for " + this.props.addon.name + ".", err); }
return BDV2.react.createElement("div", {className: "bd-card bd-addon-card settings-open ui-switch-item", ref: "cardNode"}, return BDV2.react.createElement("div", {className: "bd-card bd-addon-card settings-open ui-switch-item", ref: "cardNode"},
@ -168,7 +168,7 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
onChange() { onChange() {
this.props.toggle && this.props.toggle(this.props.addon.name); this.props.toggle && this.props.toggle(this.props.addon.name);
this.props.enabled = !this.props.enabled; this.setState({checked: !this.state.checked});
} }
edit() {this.props.edit(this.props.addon.name);} edit() {this.props.edit(this.props.addon.name);}
@ -177,8 +177,11 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
render() { render() {
if (this.state.settings) return this.settingsComponent; if (this.state.settings) return this.settingsComponent;
const name = this.getString(this.props.addon.plugin ? this.props.addon.plugin.getName() : this.props.addon.name);
const {name, author, description, version, authorId, authorLink} = this.props.addon; const author = this.getString(this.props.addon.plugin ? this.props.addon.plugin.getAuthor() : this.props.addon.author);
const description = this.getString(this.props.addon.plugin ? this.props.addon.plugin.getDescription() : this.props.addon.description);
const version = this.getString(this.props.addon.plugin ? this.props.addon.plugin.getVersion() : this.props.addon.version);
const {authorId, authorLink} = this.props.addon;
return BDV2.react.createElement("div", {className: "bd-card bd-addon-card settings-closed ui-switch-item"}, return BDV2.react.createElement("div", {className: "bd-card bd-addon-card settings-closed ui-switch-item"},
BDV2.react.createElement("div", {className: "bd-addon-header bda-header"}, BDV2.react.createElement("div", {className: "bd-addon-header bda-header"},
@ -187,7 +190,7 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
this.props.edit && this.makeButton("Edit", <EditIcon className="bd-icon" />, this.edit), this.props.edit && this.makeButton("Edit", <EditIcon className="bd-icon" />, this.edit),
this.props.remove && this.makeButton("Delete", <DeleteIcon className="bd-icon" />, this.delete), this.props.remove && this.makeButton("Delete", <DeleteIcon className="bd-icon" />, this.delete),
this.props.reload && this.makeButton("Reload", <ReloadIcon className="bd-icon" />, this.reload), this.props.reload && this.makeButton("Reload", <ReloadIcon className="bd-icon" />, this.reload),
React.createElement(Switch, {onChange: this.onChange, checked: this.props.enabled}) React.createElement(Switch, {onChange: this.onChange, checked: this.state.checked})
) )
), ),
BDV2.react.createElement("div", {className: "bd-scroller-wrap bda-description-wrap scroller-wrap fade"}, BDV2.react.createElement("div", {className: "bd-scroller-wrap bda-description-wrap scroller-wrap fade"},