Globals module
This commit is contained in:
parent
85db5af655
commit
ca8a421a9c
|
@ -18,7 +18,6 @@ class BetterDiscord {
|
|||
window.cssEditorTest = CssEditor;
|
||||
DOM.injectStyle(BdCss, 'bdmain');
|
||||
Events.on('global-ready', this.globalReady.bind(this));
|
||||
Events.emit('global-ready'); // Emit for now
|
||||
}
|
||||
|
||||
globalReady() {
|
||||
|
|
|
@ -21,10 +21,37 @@ export default new class extends Module {
|
|||
|
||||
bindings() {
|
||||
this.first = this.first.bind(this);
|
||||
this.setWS = this.setWS.bind(this);
|
||||
this.getObject = this.getObject.bind(this);
|
||||
}
|
||||
|
||||
first() {
|
||||
(async() => {
|
||||
const config = await ClientIPC.send('getConfig');
|
||||
this.setState(config);
|
||||
|
||||
Events.emit('global-ready');
|
||||
})();
|
||||
|
||||
if (window.__bd) {
|
||||
this.setState(window.__bd);
|
||||
window.__bd = {
|
||||
setWS: this.setWS
|
||||
}
|
||||
Events.emit('socket-created', this.state.wsHook);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setWS(wSocket) {
|
||||
const state = this.state;
|
||||
state.wsHook = wSocket;
|
||||
this.setState(state);
|
||||
Events.emit('socket-created');
|
||||
}
|
||||
|
||||
getObject() {
|
||||
return this.state[name];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,4 +18,8 @@ export default class {
|
|||
return localPlugins;
|
||||
}
|
||||
|
||||
static get pluginsPath() {
|
||||
return Globals.getObject('paths').find(path => path.id === 'plugins').path;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue