Handle reloading through simple inject

This commit is contained in:
Jiiks 2018-01-11 00:41:57 +02:00
parent 149a4e0dec
commit e72fb0d525
2 changed files with 29 additions and 7 deletions

16
core/dist/main.js vendored
View File

@ -16,7 +16,7 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a
* DEVELOPMENT VARIABLES
*/
const __DEV = {
TESTING: true,
TESTING: false,
clietScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js"
};
@ -73,6 +73,13 @@ class BetterDiscord {
return _asyncToGenerator(function* () {
const window = yield _this.waitForWindow();
_this.windowUtils = new WindowUtils({ window });
_this.windowUtils.webContents.on('did-finish-load', function (e) {
if (__DEV) {
_this.windowUtils.injectScript(__DEV.clietScriptPath);
}
});
setTimeout(function () {
if (__DEV) {
_this.windowUtils.injectScript(__DEV.clietScriptPath);
@ -90,11 +97,14 @@ class BetterDiscord {
resolve(windows[0]);
clearInterval(defer);
return;
} else if (false) {
//TODO Check for Discord loading finished
}
//TODO Check for Discord loading finished
if (windows.length === 1 && windows[0].webContents.getURL().includes("discordapp.com")) {
resolve(windows[0]);
clearInterval(defer);
}
//resolve(windows[0]);
//clearInterval(defer);
}, 100);
});
})();

View File

@ -13,8 +13,8 @@
* DEVELOPMENT VARIABLES
*/
const __DEV = {
TESTING: true,
clietScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js"
TESTING: false,
clientScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js"
}
const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules');
@ -61,6 +61,7 @@ class Comms {
class BetterDiscord {
constructor(args) {
this.injectScripts = this.injectScripts.bind(this);
Common.Config = new Config(args || dummyArgs);
this.comms = new Comms();
this.init();
@ -69,9 +70,12 @@ class BetterDiscord {
async init() {
const window = await this.waitForWindow();
this.windowUtils = new WindowUtils({ window });
this.windowUtils.webContents.on('did-finish-load', e => this.injectScripts(true));
setTimeout(() => {
if (__DEV) {
this.windowUtils.injectScript(__DEV.clietScriptPath);
this.ínjectScripts();
}
}, 500);
}
@ -84,7 +88,9 @@ class BetterDiscord {
resolve(windows[0]);
clearInterval(defer);
return;
}else if (false) { //TODO Check for Discord loading finished
}
if (windows.length === 1 && windows[0].webContents.getURL().includes("discordapp.com")) {
resolve(windows[0]);
clearInterval(defer);
}
@ -92,6 +98,12 @@ class BetterDiscord {
});
}
injectScripts(reload) {
if (__DEV) {
this.windowUtils.injectScript(__DEV.clientScriptPath);
}
}
get fileUtils() { return FileUtils; }
}