From 01b7e81f443d9857e4e9efb54525bbefa866ead2 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 19 Mar 2018 13:45:20 -0300 Subject: [PATCH] add global getters --- client/src/modules/contentmanager.js | 2 +- client/src/modules/globals.js | 12 ++++++++++++ client/src/modules/settings.js | 2 +- client/src/modules/updater.js | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/client/src/modules/contentmanager.js b/client/src/modules/contentmanager.js index cf2f8165..2826120c 100644 --- a/client/src/modules/contentmanager.js +++ b/client/src/modules/contentmanager.js @@ -44,7 +44,7 @@ export default class { * returns {String} */ static get contentPath() { - return this._contentPath ? this._contentPath : (this._contentPath = Globals.getObject('paths').find(path => path.id === this.pathId).path); + return Globals.getPath(this.pathId); } /** diff --git a/client/src/modules/globals.js b/client/src/modules/globals.js index f355f051..50b3dbb8 100644 --- a/client/src/modules/globals.js +++ b/client/src/modules/globals.js @@ -63,4 +63,16 @@ export default new class extends Module { return this.state[name]; } + getPath(id) { + return this.state.paths.find(path => path.id === id).path; + } + + static get paths() { + return this.state.paths; + } + + static get version() { + return this.state.version; + } + } diff --git a/client/src/modules/settings.js b/client/src/modules/settings.js index f03117bd..de4f4a0b 100644 --- a/client/src/modules/settings.js +++ b/client/src/modules/settings.js @@ -133,6 +133,6 @@ export default new class Settings { } get dataPath() { - return this._dataPath ? this._dataPath : (this._dataPath = Globals.getObject('paths').find(p => p.id === 'data').path); + return Globals.getPath('data'); } } diff --git a/client/src/modules/updater.js b/client/src/modules/updater.js index a03f9b7d..08efbc8c 100644 --- a/client/src/modules/updater.js +++ b/client/src/modules/updater.js @@ -48,8 +48,8 @@ export default class { try { Events.emit('update-check-end'); Logger.info('Updater', - `Latest Version: ${e.version} - Current Version: ${Globals.getObject('version')}`); - if (e.version !== Globals.getObject('version')) { + `Latest Version: ${e.version} - Current Version: ${Globals.version}`); + if (e.version !== Globals.version) { this.updatesAvailable = true; Events.emit('updates-available'); }