Handle reloading through simple inject
This commit is contained in:
parent
149a4e0dec
commit
e72fb0d525
|
@ -16,7 +16,7 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a
|
||||||
* DEVELOPMENT VARIABLES
|
* DEVELOPMENT VARIABLES
|
||||||
*/
|
*/
|
||||||
const __DEV = {
|
const __DEV = {
|
||||||
TESTING: true,
|
TESTING: false,
|
||||||
clietScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js"
|
clietScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,6 +73,13 @@ class BetterDiscord {
|
||||||
return _asyncToGenerator(function* () {
|
return _asyncToGenerator(function* () {
|
||||||
const window = yield _this.waitForWindow();
|
const window = yield _this.waitForWindow();
|
||||||
_this.windowUtils = new WindowUtils({ window });
|
_this.windowUtils = new WindowUtils({ window });
|
||||||
|
|
||||||
|
_this.windowUtils.webContents.on('did-finish-load', function (e) {
|
||||||
|
if (__DEV) {
|
||||||
|
_this.windowUtils.injectScript(__DEV.clietScriptPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (__DEV) {
|
if (__DEV) {
|
||||||
_this.windowUtils.injectScript(__DEV.clietScriptPath);
|
_this.windowUtils.injectScript(__DEV.clietScriptPath);
|
||||||
|
@ -90,11 +97,14 @@ class BetterDiscord {
|
||||||
resolve(windows[0]);
|
resolve(windows[0]);
|
||||||
clearInterval(defer);
|
clearInterval(defer);
|
||||||
return;
|
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]);
|
resolve(windows[0]);
|
||||||
clearInterval(defer);
|
clearInterval(defer);
|
||||||
}
|
}
|
||||||
|
//resolve(windows[0]);
|
||||||
|
//clearInterval(defer);
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* DEVELOPMENT VARIABLES
|
* DEVELOPMENT VARIABLES
|
||||||
*/
|
*/
|
||||||
const __DEV = {
|
const __DEV = {
|
||||||
TESTING: true,
|
TESTING: false,
|
||||||
clietScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js"
|
clientScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules');
|
const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules');
|
||||||
|
@ -61,6 +61,7 @@ class Comms {
|
||||||
class BetterDiscord {
|
class BetterDiscord {
|
||||||
|
|
||||||
constructor(args) {
|
constructor(args) {
|
||||||
|
this.injectScripts = this.injectScripts.bind(this);
|
||||||
Common.Config = new Config(args || dummyArgs);
|
Common.Config = new Config(args || dummyArgs);
|
||||||
this.comms = new Comms();
|
this.comms = new Comms();
|
||||||
this.init();
|
this.init();
|
||||||
|
@ -69,9 +70,12 @@ class BetterDiscord {
|
||||||
async init() {
|
async init() {
|
||||||
const window = await this.waitForWindow();
|
const window = await this.waitForWindow();
|
||||||
this.windowUtils = new WindowUtils({ window });
|
this.windowUtils = new WindowUtils({ window });
|
||||||
|
|
||||||
|
this.windowUtils.webContents.on('did-finish-load', e => this.injectScripts(true));
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (__DEV) {
|
if (__DEV) {
|
||||||
this.windowUtils.injectScript(__DEV.clietScriptPath);
|
this.ínjectScripts();
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +88,9 @@ class BetterDiscord {
|
||||||
resolve(windows[0]);
|
resolve(windows[0]);
|
||||||
clearInterval(defer);
|
clearInterval(defer);
|
||||||
return;
|
return;
|
||||||
}else if (false) { //TODO Check for Discord loading finished
|
}
|
||||||
|
|
||||||
|
if (windows.length === 1 && windows[0].webContents.getURL().includes("discordapp.com")) {
|
||||||
resolve(windows[0]);
|
resolve(windows[0]);
|
||||||
clearInterval(defer);
|
clearInterval(defer);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +98,12 @@ class BetterDiscord {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
injectScripts(reload) {
|
||||||
|
if (__DEV) {
|
||||||
|
this.windowUtils.injectScript(__DEV.clientScriptPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get fileUtils() { return FileUtils; }
|
get fileUtils() { return FileUtils; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue