smol changes
This commit is contained in:
parent
22ac7a8090
commit
be2ae143c5
File diff suppressed because one or more lines are too long
|
@ -19,7 +19,7 @@ exports.init = function(){
|
||||||
}
|
}
|
||||||
hasInit = true
|
hasInit = true
|
||||||
let readyInterval = setInterval(()=>{
|
let readyInterval = setInterval(()=>{
|
||||||
events.emit("debug", `[INIT] try ${tries++} loading LightCord`)
|
//events.emit("debug", `[INIT] try ${tries++} loading LightCord`)
|
||||||
try{
|
try{
|
||||||
if(!global.webpackJsonp)return
|
if(!global.webpackJsonp)return
|
||||||
if(!ModuleLoader.get(4))return
|
if(!ModuleLoader.get(4))return
|
||||||
|
@ -148,6 +148,9 @@ async function privateInit(){
|
||||||
DiscordJS = null
|
DiscordJS = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const appSettings = electron.remote.getGlobal("appSettings")
|
||||||
|
let Authorization = appSettings.get("LIGHTCORD_AUTH", null)
|
||||||
|
|
||||||
window.Lightcord = {
|
window.Lightcord = {
|
||||||
DiscordModules: {
|
DiscordModules: {
|
||||||
dispatcher,
|
dispatcher,
|
||||||
|
@ -156,6 +159,16 @@ async function privateInit(){
|
||||||
Settings: {
|
Settings: {
|
||||||
devMode: false,
|
devMode: false,
|
||||||
callRingingBeat: true
|
callRingingBeat: true
|
||||||
|
},
|
||||||
|
Api: {
|
||||||
|
get Authorization(){
|
||||||
|
return Authorization
|
||||||
|
},
|
||||||
|
set Authorization(data){
|
||||||
|
if(typeof data !== "string" && data !== null)return Authorization
|
||||||
|
appSettings.set("LIGHTCORD_AUTH", Authorization = data)
|
||||||
|
appSettings.save()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,9 +245,6 @@ const BetterDiscordFolder = function() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
console.log(`Original BetterDiscord Path: ${BetterDiscordFolder}
|
|
||||||
Lightcord's BetterDiscord Path: ${LightcordBDFolder}`)
|
|
||||||
|
|
||||||
path.resolve = (...args) => { // Patching BetterDiscord folder by Lightcord's BetterDiscord folder
|
path.resolve = (...args) => { // Patching BetterDiscord folder by Lightcord's BetterDiscord folder
|
||||||
let resp = originalResolve.call(path, ...args)
|
let resp = originalResolve.call(path, ...args)
|
||||||
if(resp.startsWith(BetterDiscordFolder))resp = resp.replace(BetterDiscordFolder, LightcordBDFolder)
|
if(resp.startsWith(BetterDiscordFolder))resp = resp.replace(BetterDiscordFolder, LightcordBDFolder)
|
||||||
|
|
|
@ -11,7 +11,7 @@ exports.setMainWindowVisible = setMainWindowVisible;
|
||||||
|
|
||||||
var glasstron = require("glasstron")
|
var glasstron = require("glasstron")
|
||||||
|
|
||||||
var _electron = require('electron');
|
var electron = require('electron');
|
||||||
|
|
||||||
var _path = require('path');
|
var _path = require('path');
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ const DEFAULT_HEIGHT = 720;
|
||||||
const MIN_VISIBLE_ON_SCREEN = 32;
|
const MIN_VISIBLE_ON_SCREEN = 32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Electron.BrowserWindow}
|
* @type {electron.BrowserWindow}
|
||||||
*/
|
*/
|
||||||
let mainWindow = null;
|
let mainWindow = null;
|
||||||
let mainWindowId = _Constants.DEFAULT_MAIN_WINDOW_ID;
|
let mainWindowId = _Constants.DEFAULT_MAIN_WINDOW_ID;
|
||||||
|
@ -211,7 +211,7 @@ function applyWindowBoundsToConfig(mainWindowOptions) {
|
||||||
bounds.height = Math.max(MIN_HEIGHT, bounds.height);
|
bounds.height = Math.max(MIN_HEIGHT, bounds.height);
|
||||||
|
|
||||||
let isVisibleOnAnyScreen = false;
|
let isVisibleOnAnyScreen = false;
|
||||||
const displays = _electron.screen.getAllDisplays();
|
const displays = electron.screen.getAllDisplays();
|
||||||
displays.forEach(display => {
|
displays.forEach(display => {
|
||||||
if (isVisibleOnAnyScreen) {
|
if (isVisibleOnAnyScreen) {
|
||||||
return;
|
return;
|
||||||
|
@ -362,7 +362,7 @@ function launchMainAppWindow(isVisible) {
|
||||||
|
|
||||||
applyWindowBoundsToConfig(mainWindowOptions);
|
applyWindowBoundsToConfig(mainWindowOptions);
|
||||||
|
|
||||||
mainWindow = new _electron.BrowserWindow(mainWindowOptions);
|
mainWindow = new electron.BrowserWindow(mainWindowOptions);
|
||||||
mainWindowId = mainWindow.id;
|
mainWindowId = mainWindow.id;
|
||||||
global.mainWindowId = mainWindowId;
|
global.mainWindowId = mainWindowId;
|
||||||
glasstron.update(mainWindow, {
|
glasstron.update(mainWindow, {
|
||||||
|
@ -393,7 +393,7 @@ function launchMainAppWindow(isVisible) {
|
||||||
if (frameName.startsWith(DISCORD_NAMESPACE) && windowURL.startsWith(WEBAPP_ENDPOINT)) {
|
if (frameName.startsWith(DISCORD_NAMESPACE) && windowURL.startsWith(WEBAPP_ENDPOINT)) {
|
||||||
popoutWindows.openOrFocusWindow(e, windowURL, frameName, options);
|
popoutWindows.openOrFocusWindow(e, windowURL, frameName, options);
|
||||||
} else {
|
} else {
|
||||||
_electron.shell.openExternal(windowURL);
|
electron.shell.openExternal(windowURL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ function launchMainAppWindow(isVisible) {
|
||||||
|
|
||||||
mainWindow.webContents.on('crashed', (e, killed) => {
|
mainWindow.webContents.on('crashed', (e, killed) => {
|
||||||
if (killed) {
|
if (killed) {
|
||||||
_electron.app.quit();
|
electron.app.quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ function launchMainAppWindow(isVisible) {
|
||||||
const crashTime = Date.now();
|
const crashTime = Date.now();
|
||||||
if (crashTime - lastCrashed < 5 * 1000) {
|
if (crashTime - lastCrashed < 5 * 1000) {
|
||||||
console.error('[WebContents] double crashed... RIP =(');
|
console.error('[WebContents] double crashed... RIP =(');
|
||||||
_electron.app.quit();
|
electron.app.quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastCrashed = crashTime;
|
lastCrashed = crashTime;
|
||||||
|
@ -513,7 +513,7 @@ function launchMainAppWindow(isVisible) {
|
||||||
|
|
||||||
// Quit app if that's the setting
|
// Quit app if that's the setting
|
||||||
if (!settings.get('MINIMIZE_TO_TRAY', true)) {
|
if (!settings.get('MINIMIZE_TO_TRAY', true)) {
|
||||||
_electron.app.quit();
|
electron.app.quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,8 +641,8 @@ function setupUpdaterIPC() {
|
||||||
try {
|
try {
|
||||||
moduleUpdater.quitAndInstallUpdates();
|
moduleUpdater.quitAndInstallUpdates();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_electron.app.relaunch();
|
electron.app.relaunch();
|
||||||
_electron.app.quit();
|
electron.app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -666,26 +666,26 @@ function init() {
|
||||||
// electron default behavior is to app.quit here, so long as there are no other listeners. we handle quitting
|
// electron default behavior is to app.quit here, so long as there are no other listeners. we handle quitting
|
||||||
// or minimizing to system tray ourselves via mainWindow.on('closed') so this is simply to disable the electron
|
// or minimizing to system tray ourselves via mainWindow.on('closed') so this is simply to disable the electron
|
||||||
// default behavior.
|
// default behavior.
|
||||||
_electron.app.on('window-all-closed', () => {});
|
electron.app.on('window-all-closed', () => {});
|
||||||
|
|
||||||
_electron.app.on('before-quit', () => {
|
electron.app.on('before-quit', () => {
|
||||||
saveWindowConfig(mainWindow);
|
saveWindowConfig(mainWindow);
|
||||||
mainWindow = null;
|
mainWindow = null;
|
||||||
notificationScreen.close();
|
notificationScreen.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: move this to main startup
|
// TODO: move this to main startup
|
||||||
_electron.app.on('gpu-process-crashed', (e, killed) => {
|
electron.app.on('gpu-process-crashed', (e, killed) => {
|
||||||
if (killed) {
|
if (killed) {
|
||||||
_electron.app.quit();
|
electron.app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_electron.app.on('accessibility-support-changed', (_event, accessibilitySupportEnabled) => webContentsSend('ACCESSIBILITY_SUPPORT_CHANGED', accessibilitySupportEnabled));
|
electron.app.on('accessibility-support-changed', (_event, accessibilitySupportEnabled) => webContentsSend('ACCESSIBILITY_SUPPORT_CHANGED', accessibilitySupportEnabled));
|
||||||
|
|
||||||
_electron.app.on(_Constants.MenuEvents.OPEN_HELP, () => webContentsSend('HELP_OPEN'));
|
electron.app.on(_Constants.MenuEvents.OPEN_HELP, () => webContentsSend('HELP_OPEN'));
|
||||||
_electron.app.on(_Constants.MenuEvents.OPEN_SETTINGS, () => webContentsSend('USER_SETTINGS_OPEN'));
|
electron.app.on(_Constants.MenuEvents.OPEN_SETTINGS, () => webContentsSend('USER_SETTINGS_OPEN'));
|
||||||
_electron.app.on(_Constants.MenuEvents.CHECK_FOR_UPDATES, () => moduleUpdater.checkForUpdates());
|
electron.app.on(_Constants.MenuEvents.CHECK_FOR_UPDATES, () => moduleUpdater.checkForUpdates());
|
||||||
|
|
||||||
_ipcMain2.default.on('SETTINGS_UPDATE_BACKGROUND_COLOR', (_event, backgroundColor) => {
|
_ipcMain2.default.on('SETTINGS_UPDATE_BACKGROUND_COLOR', (_event, backgroundColor) => {
|
||||||
if (getBackgroundColor() !== backgroundColor) {
|
if (getBackgroundColor() !== backgroundColor) {
|
||||||
|
|
Loading…
Reference in New Issue