BetterDiscordApp-v2/core/src/modules/config.js

78 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-01-10 20:19:34 +01:00
/**
* BetterDiscord Config Module
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
2018-03-21 18:41:27 +01:00
* LICENSE file in the root directory of this source tree.
2018-01-10 20:19:34 +01:00
*/
2018-05-28 02:52:12 +02:00
import Module from './modulebase';
2018-01-10 17:02:29 +01:00
2018-05-28 02:52:12 +02:00
export default class Config extends Module {
2018-01-10 17:02:29 +01:00
get version() {
return this.args.version;
}
2019-03-05 22:26:17 +01:00
get versions() {
return {
core: this.coreVersion,
client: this.clientVersion,
editor: this.editorVersion
};
}
get coreVersion() {
return this.state.coreVersion;
}
2019-02-17 10:12:12 +01:00
get clientVersion() {
return this.state.clientVersion;
}
get editorVersion() {
return this.state.editorVersion;
2019-02-17 10:12:12 +01:00
}
setClientVersion(clientVersion) {
2019-03-07 20:09:48 +01:00
this.state.clientVersion = clientVersion;
}
setCoreVersion(coreVersion) {
this.state.coreVersion = coreVersion;
}
setEditorVersion(editorVersion) {
this.state.editorVersion = editorVersion;
2019-02-17 10:12:12 +01:00
}
2018-01-10 17:02:29 +01:00
get paths() {
return this.args.paths;
}
2018-03-21 21:47:46 +01:00
getPath(id, full) {
2019-02-17 11:18:16 +01:00
const path = this.paths.find(p => p.id === id);
2019-02-28 14:20:36 +01:00
if (!path) return null;
2019-02-17 11:18:16 +01:00
return full ? path : path.path;
2018-03-21 21:47:46 +01:00
}
2019-02-17 10:12:12 +01:00
addPath(id, path) {
2019-02-17 11:18:16 +01:00
this.paths.push({ id, path });
2019-02-17 10:12:12 +01:00
}
2018-01-10 17:02:29 +01:00
get config() {
return {
2018-03-21 18:41:27 +01:00
version: this.version,
2019-03-05 22:26:17 +01:00
versions: this.versions,
2018-03-21 18:41:27 +01:00
paths: this.paths
2018-01-10 17:02:29 +01:00
};
}
2019-02-17 11:18:16 +01:00
// Compatibility with old client code and new installer args
compatibility() {
this.args.paths = Object.entries(this.args.paths).map(([id, path]) => ({ id, path }));
}
2018-01-10 17:02:29 +01:00
}