fix plugin settings panels and rdt
This commit is contained in:
parent
a4f9d61c79
commit
dde0d606ce
|
@ -50,6 +50,7 @@
|
|||
"Reflect": "readonly",
|
||||
"DiscordNative": "readonly",
|
||||
"__non_webpack_require__": "readonly",
|
||||
"Symbol": "readonly",
|
||||
|
||||
"alert": "off",
|
||||
"atob": "off",
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,6 @@ const fs = require("fs");
|
|||
const path = require("path");
|
||||
|
||||
const BrowserWindow = electron.remote.BrowserWindow;
|
||||
const webContents = electron.remote.getCurrentWebContents();
|
||||
|
||||
export default new class ReactDevTools extends Builtin {
|
||||
get name() {return "ReactDevTools";}
|
||||
|
@ -32,26 +31,19 @@ export default new class ReactDevTools extends Builtin {
|
|||
}
|
||||
this.extensionPath = extensionPath;
|
||||
this.isExtensionInstalled = fs.existsSync(extensionPath);
|
||||
this.listener = this.listener.bind(this);
|
||||
}
|
||||
|
||||
enabled() {
|
||||
if (!this.isExtensionInstalled) this.findExtension();
|
||||
if (!this.isExtensionInstalled) return Modals.alert(Strings.ReactDevTools.notFound, Strings.ReactDevTools.notFoundDetails);
|
||||
setImmediate(() => webContents.on("devtools-opened", this.listener));
|
||||
if (webContents.isDevToolsOpened()) this.listener();
|
||||
}
|
||||
|
||||
disabled() {
|
||||
webContents.removeListener("devtools-opened", this.listener);
|
||||
}
|
||||
|
||||
listener() {
|
||||
if (!this.isExtensionInstalled) return;
|
||||
BrowserWindow.removeDevToolsExtension("React Developer Tools");
|
||||
const didInstall = BrowserWindow.addDevToolsExtension(this.extensionPath);
|
||||
|
||||
if (didInstall) this.log("Successfully installed react devtools.");
|
||||
else this.error("Couldn't find react devtools in chrome extensions!");
|
||||
}
|
||||
|
||||
disabled() {
|
||||
if (!this.isExtensionInstalled) return;
|
||||
BrowserWindow.removeDevToolsExtension("React Developer Tools");
|
||||
}
|
||||
};
|
13
src/index.js
13
src/index.js
|
@ -10,15 +10,4 @@ patchModuleLoad();
|
|||
window.BdApi = BdApi;
|
||||
|
||||
// Add loading icon at the bottom right
|
||||
LoadingIcon.show();
|
||||
|
||||
// Backwards compatibility for now
|
||||
export default class CoreWrapper {
|
||||
constructor(config) {
|
||||
Core.setConfig(config);
|
||||
}
|
||||
|
||||
init() {
|
||||
Core.init();
|
||||
}
|
||||
}
|
||||
LoadingIcon.show();
|
|
@ -102,9 +102,13 @@ export default class AddonCard extends React.Component {
|
|||
props.dangerouslySetInnerHTML = this.settingsPanel;
|
||||
}
|
||||
|
||||
let child = null;
|
||||
if (typeof(this.settingsPanel) === "function") child = <this.settingsPanel />;
|
||||
if (this.settingsPanel.$$typeof && this.settingsPanel.$$typeof === Symbol.for("react.element")) child = this.settingsPanel;
|
||||
|
||||
return <div className="bd-addon-card settings-open bd-switch-item">
|
||||
<div className="bd-close" onClick={this.closeSettings}><CloseButton /></div>
|
||||
<div {...props}><ErrorBoundary>{this.settingsPanel instanceof React.Component || typeof(this.settingsPanel) === "function" ? this.settingsPanel : null}</ErrorBoundary></div>
|
||||
<div {...props}><ErrorBoundary>{child}</ErrorBoundary></div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue