From 081a330830d7a4e19896741b699f9c897aee5d8c Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 30 Jan 2022 20:45:38 +0200 Subject: [PATCH] Fixed actions execution issues in the launcher's core libraries --- package.json | 2 +- src/defaultSettings.ts | 6 ++++-- src/index.svelte | 10 ---------- src/pages/index.ts | 2 -- src/ts/Launcher.ts | 25 ++++++++++++++++++++----- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 6a52057..d9734f3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "check": "svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@empathize/framework": "^1.4.2", + "@empathize/framework": "^1.4.3", "js-md5": "^0.7.3", "semver": "^7.3.5", "svelte-i18n": "^3.3.13", diff --git a/src/defaultSettings.ts b/src/defaultSettings.ts index f691c7a..56635c9 100644 --- a/src/defaultSettings.ts +++ b/src/defaultSettings.ts @@ -3,8 +3,8 @@ import { Configs, promisify } from './empathize'; import constants from './ts/Constants'; import Locales from './ts/launcher/Locales'; -promisify(async () => { - Configs.defaults({ +export default new Promise(async (resolve) => { + await Configs.defaults({ lang: { launcher: await Locales.system(), voice: [ @@ -199,4 +199,6 @@ promisify(async () => { launcher: '5d' } }); + + resolve(); }); diff --git a/src/index.svelte b/src/index.svelte index 48f8e8c..a93f4c3 100644 --- a/src/index.svelte +++ b/src/index.svelte @@ -17,16 +17,6 @@ import GearActive from './assets/images/gear-active.png'; import Download from './assets/images/cloud-download.png'; - constants.paths.launcherDir.then((dir) => { - // Create launcher folder if it doesn't exist - Neutralino.filesystem.getStats(dir) - .catch(() => Neutralino.filesystem.createDirectory(dir)); - - // Create logs folder if it doesn't exist - Neutralino.filesystem.getStats(`${dir}/logs`) - .catch(() => Neutralino.filesystem.createDirectory(`${dir}/logs`)); - }); - const launcher = new Launcher(onMount); Neutralino.events.on('ready', () => { diff --git a/src/pages/index.ts b/src/pages/index.ts index 4f2fb95..db016c1 100644 --- a/src/pages/index.ts +++ b/src/pages/index.ts @@ -5,8 +5,6 @@ declare const Neutralino; Neutralino.init(); -Neutralino.events.on('ready', () => import('../defaultSettings')); - const app = new App({ target: document.getElementById('app')! }); diff --git a/src/ts/Launcher.ts b/src/ts/Launcher.ts index ca60354..5c51c58 100644 --- a/src/ts/Launcher.ts +++ b/src/ts/Launcher.ts @@ -2,7 +2,7 @@ import { locale } from 'svelte-i18n'; import { Windows, Process, Tray, - Configs, Debug, IPC + Configs, Debug, IPC, fs, path } from '../empathize'; import constants from './Constants'; @@ -36,11 +36,26 @@ export default class Launcher this.tray = new Tray(`/public/icons/256x256.png`); this.tray.update(); - this.updateDiscordRPC('in-launcher'); + onMount(async () => { + const launcherDir = await constants.paths.launcherDir; - onMount(() => { - this.progressBar = new ProgressBar(this); - this.state = new State(this); + // Create launcher folder if it doesn't exist + if (!await fs.exists(launcherDir)) + await fs.mkdir(launcherDir); + + // Create logs folder if it doesn't exist + if (!await fs.exists(path.join(launcherDir, 'logs'))) + await fs.mkdir(path.join(launcherDir, 'logs')); + + // Applying default settings + const defaultSetings = (await import('../defaultSettings')).default; + + defaultSetings.then(() => { + this.updateDiscordRPC('in-launcher'); + + this.progressBar = new ProgressBar(this); + this.state = new State(this); + }); }); }