Skip to content

Commit

Permalink
🐛 #97 correct config download and damage accurate option
Browse files Browse the repository at this point in the history
Signed-off-by: JAGFx <contact@jagfx.fr>
  • Loading branch information
JAGFx committed Jan 31, 2022
1 parent ce6fcd8 commit cdbc4c6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 92 deletions.
2 changes: 1 addition & 1 deletion doc/BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The configuration files are divided into two files:
- The minimal configuration of the application `config.json`
- The configuration of the game `config.ets2.json` or `config.ats.json`

The old config file `config.ets2-dashboard-skin.json` is deprecated and is not used anymore.
The old config file `config.ets2-dashboard-skin.json` is removed and is not used anymore.

If you have changes for the following entries, edit `config.json`:

Expand Down
29 changes: 16 additions & 13 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ import path from 'path';
import { ConfigurationException } from './exceptions.js';
import store from './store.js';

/**
* @deprecated
*/
const oldConfigPath = () => {
const configBasePath = store.get('configBasePath');
return path.resolve(
configBasePath,
'./config/config.ets2-dashboard-skin.json'
);
};

export const initAppConfig = () => {
return new Promise((resolve) => {
store.set('config', {
Expand All @@ -36,7 +25,14 @@ export const appConfigPath = () => {
const configBasePath = store.get('configBasePath');
const newAppConfigPath = path.resolve(configBasePath, `./config/config.json`);

return existsSync(newAppConfigPath) ? newAppConfigPath : oldConfigPath();
if (!existsSync(newAppConfigPath)) {
throw new ConfigurationException(
'Unable to load the configuration application file',
{ newAppConfigPath, reason: 'File not found' }
);
}

return newAppConfigPath;
};

export const gameConfigPath = (gameId) => {
Expand All @@ -46,7 +42,14 @@ export const gameConfigPath = (gameId) => {
`./config/config.${gameId}.json`
);

return existsSync(newGameConfigPath) ? newGameConfigPath : oldConfigPath();
if (!existsSync(newGameConfigPath)) {
throw new ConfigurationException(
'Unable to load the game application file',
{ newGameConfigPath, reason: 'File not found', gameId }
);
}

return newGameConfigPath;
};

export const appConfig = () => {
Expand Down
1 change: 0 additions & 1 deletion lib/config/config.ats.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"maps_map_activeMap" : null,
"maps_map_navigationRemaining" : "remaining_date",
"maps_map_tilesVersion" : "latest",
"general_damage_accurate" : "damage-diagnostic",
"jagfx_elements_right_map" : false,
"maps_map_tilesRemoteUseCustom" : false,
"maps_map_tilesRemoteCustomPath" : null,
Expand Down
72 changes: 0 additions & 72 deletions lib/config/config.ets2-dashboard-skin.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/config/config.ets2.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"maps_map_activeMap" : null,
"maps_map_navigationRemaining" : "remaining_date",
"maps_map_tilesVersion" : "latest",
"general_damage_accurate" : "damage-diagnostic",
"jagfx_elements_right_map" : false,
"maps_map_tilesRemoteUseCustom" : false,
"maps_map_tilesRemoteCustomPath" : null,
Expand Down
3 changes: 2 additions & 1 deletion lib/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"general_h-shift-layout" : "h-shifter",
"general_skin_locale" : "en-EN",
"general_job_remaining" : "due_date",
"general_port": 3000
"general_port": 3000,
"general_damage_accurate": "damage-diagnostic"
}
7 changes: 4 additions & 3 deletions src/utils/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ export const save = async (data, target) => {
);
};

export const download = (target, gameId) => {
return load(target, gameId).then((data) => {
export const download = (target) => {
return load(target).then((data) => {
const gameId = telemetryStore.telemetry.game.game.name;
const fileName = target === 'app' ? 'config.json' : `config.${gameId}.json`;

const file = new File([JSON.stringify(data, null, 2)], fileName, {
Expand All @@ -105,7 +106,7 @@ export const load = (target) => {
if (useFakeData)
return new Promise((resolve) => {
setTimeout(() => {
resolve(store.getters[`config/${target}`] ?? emptyData().app);
resolve(store.getters[`config/${target}`] ?? emptyData()[target]);
}, 1000);
});

Expand Down

0 comments on commit cdbc4c6

Please sign in to comment.