Fixed reload crashing and serverlist inject

Not ready for release yet.
This commit is contained in:
Jiiks 2015-12-11 04:46:03 +02:00
parent 493944e991
commit 1fec4fbaa8
3 changed files with 57 additions and 15 deletions

View File

@ -193,32 +193,74 @@ BetterDiscord.prototype.quit = function(reason) {
var ipcHooked = false;
BetterDiscord.prototype.domReady = function() {
_this.getUtils().log("Hooked dom-ready");
if(_updater.LatestVersion > _version) {
_this.getUtils().execJs('alert("An update for BetterDiscord is available(v'+ _updater.LatestVersion +')! Download the latest version from GitHub!")');
}
if(ipcHooked) {
_this.load(true);
return;
}
ipcHooked = true;
_this.load(false);
};
BetterDiscord.prototype.load = function(reload) {
_this.getUtils().log("Hooked dom-ready");
if(reload) {
_this.getUtils().log("Reloading");
}
if(!reload) {
if(_updater.LatestVersion > _version) {
_this.getUtils().execJs('alert("An update for BetterDiscord is available(v'+ _updater.LatestVersion +')! Download the latest version from GitHub!")');
}
}
//Create loading element
_this.getUtils().execJs('var loadingNode = document.createElement("DIV");');
_this.getUtils().execJs('loadingNode.innerHTML = \' <div style="height:30px;width:100%;background:#282B30;"><div style="padding-right:10px; float:right"> <span id="bd-status" style="line-height:30px;color:#E8E8E8;">BetterDiscord - Loading Libraries : </span><progress id="bd-pbar" value="10" max="100"></progress></div></div> \'');
_this.getUtils().execJs('var flex = document.getElementsByClassName("flex-vertical flex-spacer")[0]; flex.appendChild(loadingNode);');
//Create ipc
_this.getUtils().execJs("var betterDiscordIPC = require('ipc');");
if(!reload) {
_this.getUtils().log("Hooking ipc async");
_ipc.on('asynchronous-message', function(event, arg) { _this.ipcAsyncMessage(event, arg); });
_this.getUtils().log("Hooked ipc async");
}
//Inject version
_this.getUtils().execJs('var version = "'+_version+'"');
//Load jQuery
_this.getUtils().updateLoading("Loading Resources(jQuery)", 0, 100);
_this.getUtils().injectJavaScriptSync("//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", "load-jQueryUI");
};
BetterDiscord.prototype.reload = function() {
_this.getUtils().log("Reloading...");
//Create loading element
_this.getUtils().execJs('var loadingNode = document.createElement("DIV");');
_this.getUtils().execJs('loadingNode.innerHTML = \' <div style="height:30px;width:100%;background:#282B30;"><div style="padding-right:10px; float:right"> <span id="bd-status" style="line-height:30px;color:#E8E8E8;">BetterDiscord - Loading Libraries : </span><progress id="bd-pbar" value="10" max="100"></progress></div></div> \'');
_this.getUtils().execJs('var flex = document.getElementsByClassName("flex-vertical flex-spacer")[0]; flex.appendChild(loadingNode);');
//Create ipc
//Recreate ipc
_this.getUtils().execJs("var betterDiscordIPC = require('ipc');");
_this.getUtils().log("Hooking ipc async");
_ipc.on('asynchronous-message', function(event, arg) { _this.ipcAsyncMessage(event, arg); });
_this.getUtils().log("Hooked ipc async");
//Inject version
_this.getUtils().execJs('var version = "'+_version+'"');
//Load jQuery
_this.getUtils().updateLoading("Loading Resources(jQuery)", 0, 100);
_this.getUtils().injectJavaScriptSync("//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", "load-jQueryUI");
};
var loadCount = 0;
BetterDiscord.prototype.ipcAsyncMessage = function(event, arg) {
var libCount = 9;
@ -258,7 +300,7 @@ BetterDiscord.prototype.ipcAsyncMessage = function(event, arg) {
'type': 'json',
'resource': 'Public Servers',
'domain': _updater.CDN,
'url': '//' + _repo + '/BetterDiscordApp/' + _hash + 'serverlist.json',
'url': '/' + _repo + '/BetterDiscordApp/' + _hash + '/serverlist.json',
'localurl': null,
'message': 'load-emoteData-twitchGlobal',
'cacheable': false,
@ -341,7 +383,7 @@ BetterDiscord.prototype.ipcAsyncMessage = function(event, arg) {
}
};
var loadCount = 0;
if(loadUs.hasOwnProperty(arg)) {
loadCount++;

View File

@ -1,6 +1,6 @@
{
"Core": {
"Version": "0.2.2"
"Version": "0.2.3"
},
"EmoteModule": {
"Twitch":{

View File

@ -1,7 +1,7 @@
{
"name": "betterdiscord",
"description": "Better Discord enhances Discord.",
"version": "0.2.2",
"version": "0.2.3",
"homepage": "https://github.com/Jiiks/BetterDiscordApp",
"license": "MIT",
"main": "betterdiscord.js"