Fixed Downloads

This commit is contained in:
Geomitron
2020-03-04 18:17:54 -05:00
parent 4ebf2db650
commit db02710b37
16 changed files with 480 additions and 396 deletions

View File

@@ -14,20 +14,20 @@ let settings: Settings
/**
* Handles the 'get-settings' event.
*/
export class GetSettingsHandler implements IPCInvokeHandler<'get-settings'> {
class GetSettingsHandler implements IPCInvokeHandler<'get-settings'> {
event: 'get-settings' = 'get-settings'
/**
* @returns the current settings oject, or default settings if they couldn't be loaded.
*/
handler() {
return GetSettingsHandler.getSettings()
return this.getSettings()
}
/**
* @returns the current settings oject, or default settings if they couldn't be loaded.
*/
static getSettings() {
getSettings() {
if (settings == undefined) {
return defaultSettings
} else {
@@ -40,7 +40,7 @@ export class GetSettingsHandler implements IPCInvokeHandler<'get-settings'> {
* Otherwise, loads user settings from data directories.
* If this process fails, default settings are used.
*/
static async initSettings() {
async initSettings() {
try {
// Create data directories if they don't exists
for (const path of [dataPath, tempPath, themesPath]) {
@@ -67,7 +67,7 @@ export class GetSettingsHandler implements IPCInvokeHandler<'get-settings'> {
/**
* Handles the 'set-settings' event.
*/
export class SetSettingsHandler implements IPCEmitHandler<'set-settings'> {
class SetSettingsHandler implements IPCEmitHandler<'set-settings'> {
event: 'set-settings' = 'set-settings'
/**
@@ -85,4 +85,7 @@ export class SetSettingsHandler implements IPCEmitHandler<'set-settings'> {
const settingsJSON = JSON.stringify(settings, undefined, 2)
await writeFile(settingsPath, settingsJSON, 'utf8')
}
}
}
export const getSettingsHandler = new GetSettingsHandler()
export const setSettingsHandler = new SetSettingsHandler()