From 38c61484c19ff268e76d571ab25da0af37ad7c6c Mon Sep 17 00:00:00 2001 From: Jiiks Date: Thu, 11 Jan 2018 14:37:52 +0200 Subject: [PATCH] Paths for plugins and themes --- core/dist/main.js | 30 +++++++++++++++++++++--------- core/src/main.js | 20 +++++++++++++++----- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/core/dist/main.js b/core/dist/main.js index 202301f9..9521d216 100644 --- a/core/dist/main.js +++ b/core/dist/main.js @@ -17,9 +17,14 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a */ const __DEV = { TESTING: false, - clietScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js" + clientScriptPath: 'G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js' }; +const path = require('path'); + +const __pluginPath = path.resolve(__dirname, '..', '..', 'tests', 'plugins'); +const __themePath = path.resolve(__dirname, '..', '..', 'tests', 'themes'); + const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules'); const { BrowserWindow } = require('electron'); @@ -27,9 +32,11 @@ const Common = {}; const dummyArgs = { 'version': '0.3.1', - 'paths': [{ 'base': 'basePath' }, { 'plugins': 'pluginsPath' }, { 'themes': 'themesPath' }] + 'paths': [{ 'base': 'basePath' }, { 'plugins': __pluginPath }, { 'themes': __themePath }] }; +console.log(dummyArgs); + class Comms { constructor() { @@ -62,9 +69,12 @@ class Comms { class BetterDiscord { constructor(args) { + this.injectScripts = this.injectScripts.bind(this); Common.Config = new Config(args || dummyArgs); this.comms = new Comms(); this.init(); + console.log("PLUGINS PATH:"); + console.log(dummyArgs.paths.plugins); } init() { @@ -75,14 +85,12 @@ class BetterDiscord { _this.windowUtils = new WindowUtils({ window }); _this.windowUtils.webContents.on('did-finish-load', function (e) { - if (__DEV) { - _this.windowUtils.injectScript(__DEV.clietScriptPath); - } + return _this.injectScripts(true); }); setTimeout(function () { if (__DEV) { - _this.windowUtils.injectScript(__DEV.clietScriptPath); + _this.injectScripts(); } }, 500); })(); @@ -98,18 +106,22 @@ class BetterDiscord { clearInterval(defer); return; } - //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); }); })(); } + injectScripts(reload = false) { + if (__DEV) { + this.windowUtils.injectScript(__DEV.clientScriptPath); + } + } + get fileUtils() { return FileUtils; } diff --git a/core/src/main.js b/core/src/main.js index 60869178..9c91e308 100644 --- a/core/src/main.js +++ b/core/src/main.js @@ -14,9 +14,14 @@ */ const __DEV = { TESTING: false, - clientScriptPath: "G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js" + clientScriptPath: 'G:/Github/JsSucks/BetterDiscordApp/client/dist/betterdiscord.client.js' } +const path = require('path'); + +const __pluginPath = path.resolve(__dirname, '..', '..', 'tests', 'plugins'); +const __themePath = path.resolve(__dirname, '..', '..', 'tests', 'themes'); + const { Utils, FileUtils, BDIpc, Config, WindowUtils } = require('./modules'); const { BrowserWindow } = require('electron'); @@ -26,11 +31,14 @@ const dummyArgs = { 'version': '0.3.1', 'paths': [ { 'base': 'basePath' }, - { 'plugins': 'pluginsPath' }, - { 'themes': 'themesPath' } + { 'plugins': __pluginPath }, + { 'themes': __themePath } ] }; +console.log(dummyArgs); + + class Comms { constructor() { @@ -65,6 +73,8 @@ class BetterDiscord { Common.Config = new Config(args || dummyArgs); this.comms = new Comms(); this.init(); + console.log("PLUGINS PATH:"); + console.log(dummyArgs.paths.plugins); } async init() { @@ -75,7 +85,7 @@ class BetterDiscord { setTimeout(() => { if (__DEV) { - this.ínjectScripts(); + this.injectScripts(); } }, 500); } @@ -98,7 +108,7 @@ class BetterDiscord { }); } - injectScripts(reload) { + injectScripts(reload = false) { if (__DEV) { this.windowUtils.injectScript(__DEV.clientScriptPath); }