From d01a8d578bdd79de80468bc2c22c7d361bffe974 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Wed, 11 Dec 2019 00:08:45 +0900 Subject: [PATCH] refs #1163 Use default preference if the file does not exist when get proxy configuration --- src/main/preferences.ts | 12 ++++++------ src/main/proxy.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/preferences.ts b/src/main/preferences.ts index 9ecf4668..1eef83e8 100644 --- a/src/main/preferences.ts +++ b/src/main/preferences.ts @@ -93,9 +93,9 @@ export default class Preferences { this.path = path } - async load(): Promise { + public async load(): Promise { try { - const preferences = await this.get() + const preferences = await this._get() return objectAssignDeep({}, Base, preferences) } catch (err) { log.error(err) @@ -103,7 +103,7 @@ export default class Preferences { } } - get(): Promise { + private _get(): Promise { return new Promise((resolve, reject) => { storage.get(this.path, (err, data) => { if (err) return reject(err) @@ -112,7 +112,7 @@ export default class Preferences { }) } - save(data: BaseConfig): Promise { + private _save(data: BaseConfig): Promise { return new Promise((resolve, reject) => { storage.set(this.path, data, err => { if (err) return reject(err) @@ -121,10 +121,10 @@ export default class Preferences { }) } - async update(obj: any): Promise { + public async update(obj: any): Promise { const current = await this.load() const data = objectAssignDeep({}, current, obj) - const result = await this.save(data) + const result = await this._save(data) return result } } diff --git a/src/main/proxy.ts b/src/main/proxy.ts index 19eaa842..76bd102e 100644 --- a/src/main/proxy.ts +++ b/src/main/proxy.ts @@ -44,7 +44,7 @@ export default class ProxyConfiguration { } public async getConfig(): Promise { - const conf = await this.preferences.get() + const conf = await this.preferences.load() const source = conf.proxy.source as ProxySource switch (source) { case ProxySource.no: