Globals module

This commit is contained in:
Jiiks 2018-01-30 15:25:35 +02:00
parent 85db5af655
commit ca8a421a9c
3 changed files with 32 additions and 2 deletions

View File

@ -18,7 +18,6 @@ class BetterDiscord {
window.cssEditorTest = CssEditor; window.cssEditorTest = CssEditor;
DOM.injectStyle(BdCss, 'bdmain'); DOM.injectStyle(BdCss, 'bdmain');
Events.on('global-ready', this.globalReady.bind(this)); Events.on('global-ready', this.globalReady.bind(this));
Events.emit('global-ready'); // Emit for now
} }
globalReady() { globalReady() {

View File

@ -21,10 +21,37 @@ export default new class extends Module {
bindings() { bindings() {
this.first = this.first.bind(this); this.first = this.first.bind(this);
this.setWS = this.setWS.bind(this);
this.getObject = this.getObject.bind(this);
} }
first() { 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];
} }
} }

View File

@ -18,4 +18,8 @@ export default class {
return localPlugins; return localPlugins;
} }
static get pluginsPath() {
return Globals.getObject('paths').find(path => path.id === 'plugins').path;
}
} }