can't wait for dual maintenance to end

This commit is contained in:
Zack Rauen 2020-03-23 23:21:22 -04:00
parent 45b36b6a86
commit 652b8430be
6 changed files with 52 additions and 24 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

@ -253,48 +253,45 @@ BdApi.setBDData = function(key, data) {
class AddonAPI { const makeAddonAPI = (cookie, list, manager) => new class AddonAPI {
constructor(cookie, list, manager) {
this._manager = manager;
this._cookie = cookie;
this._list = list;
}
isEnabled(name) { isEnabled(name) {
return !!this._cookie[name]; return !!cookie[name];
} }
enable(name) { enable(name) {
return this._manager.enable(name); return manager.enable(name);
} }
disable(name) { disable(name) {
return this._manager.disable(name); return manager.disable(name);
} }
toggle(name) { toggle(name) {
if (this._cookie[name]) this.disable(name); if (cookie[name]) this.disable(name);
else this.enable(name); else this.enable(name);
} }
reload(name) { reload(name) {
return this._manager.reload(name); return manager.reload(name);
} }
get(name) { get(name) {
if (this._list.hasOwnProperty(name)) { if (list.hasOwnProperty(name)) {
if (this._list[name].plugin) return this._list[name].plugin; if (list[name].plugin) return list[name].plugin;
return this._list[name]; return list[name];
} }
return null; return null;
} }
getAll() { getAll() {
return Object.keys(this._list).map(k => this.get(k)).filter(a => a); return Object.keys(list).map(k => this.get(k)).filter(a => a);
} }
} };
BdApi.Plugins = new AddonAPI(pluginCookie, bdplugins, pluginModule); BdApi.Plugins = makeAddonAPI(pluginCookie, bdplugins, pluginModule);
BdApi.Themes = new AddonAPI(themeCookie, bdthemes, themeModule); BdApi.Themes = makeAddonAPI(themeCookie, bdthemes, themeModule);
Object.freeze(BdApi);
export default BdApi; export default BdApi;

View File

@ -0,0 +1,17 @@
import BDV2 from "../v2";
export default class BDErrorBoundary extends BDV2.reactComponent {
constructor(props) {
super(props);
this.state = {hasError: false};
}
componentDidCatch() {
this.setState({hasError: true});
}
render() {
if (this.state.hasError) return BDV2.react.createElement("div", {className: "react-error"}, "Component Error");
return this.props.children;
}
}

View File

@ -78,6 +78,7 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
} }
getString(value) { getString(value) {
if (!value) return "???";
return typeof value == "string" ? value : value.toString(); return typeof value == "string" ? value : value.toString();
} }

View File

@ -28,6 +28,7 @@ import SectionedSettingsPanel from "./react/sectionedSettingsPanel";
import SettingsPanel from "./react/settingsPanel"; import SettingsPanel from "./react/settingsPanel";
import CssEditor from "./react/cssEditor"; import CssEditor from "./react/cssEditor";
import ContentColumn from "./react/contentColumn"; import ContentColumn from "./react/contentColumn";
import ErrorBoundary from "./react/errorBoundary";
export default new class V2_SettingsPanel { export default new class V2_SettingsPanel {
@ -292,7 +293,7 @@ export default new class V2_SettingsPanel {
get pluginsComponent() { get pluginsComponent() {
const plugins = Object.keys(bdplugins).sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())).reduce((arr, key) => { const plugins = Object.keys(bdplugins).sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())).reduce((arr, key) => {
arr.push(BDV2.react.createElement(PluginCard, {key: key, plugin: bdplugins[key].plugin}));return arr; arr.push(BDV2.react.createElement(ErrorBoundary, null, BDV2.react.createElement(PluginCard, {key: key, plugin: bdplugins[key].plugin})));return arr;
}, []); }, []);
const list = BDV2.react.createElement(List, {key: "plugin-list", className: "bda-slist", children: plugins}); const list = BDV2.react.createElement(List, {key: "plugin-list", className: "bda-slist", children: plugins});
const refreshIcon = !settingsCookie["fork-ps-5"] && BDV2.react.createElement(TooltipWrap(ReloadIcon, {color: "black", side: "top", text: "Reload Plugin List"}), {className: "bd-reload-header", size: "18px", onClick: async () => { const refreshIcon = !settingsCookie["fork-ps-5"] && BDV2.react.createElement(TooltipWrap(ReloadIcon, {color: "black", side: "top", text: "Reload Plugin List"}), {className: "bd-reload-header", size: "18px", onClick: async () => {
@ -306,7 +307,7 @@ export default new class V2_SettingsPanel {
get themesComponent() { get themesComponent() {
const themes = Object.keys(bdthemes).sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())).reduce((arr, key) => { const themes = Object.keys(bdthemes).sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())).reduce((arr, key) => {
arr.push(BDV2.react.createElement(ThemeCard, {key: key, theme: bdthemes[key]}));return arr; arr.push(BDV2.react.createElement(ErrorBoundary, null, BDV2.react.createElement(ThemeCard, {key: key, theme: bdthemes[key]})));return arr;
}, []); }, []);
const list = BDV2.react.createElement(List, {key: "theme-list", className: "bda-slist", children: themes}); const list = BDV2.react.createElement(List, {key: "theme-list", className: "bda-slist", children: themes});
const refreshIcon = !settingsCookie["fork-ps-5"] && BDV2.react.createElement(TooltipWrap(ReloadIcon, {color: "black", side: "top", text: "Reload Theme List"}), {className: "bd-reload-header", size: "18px", onClick: async () => { const refreshIcon = !settingsCookie["fork-ps-5"] && BDV2.react.createElement(TooltipWrap(ReloadIcon, {color: "black", side: "top", text: "Reload Theme List"}), {className: "bd-reload-header", size: "18px", onClick: async () => {