Skip to content

Commit

Permalink
convert mod_data_dir keys back to int upon load
Browse files Browse the repository at this point in the history
  • Loading branch information
tappi287 committed Jan 25, 2022
1 parent 8df0202 commit dc5da6f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/app_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ def set_mod_dir_fn(directory_str, mod_type: int):

# -- Reset
if not directory_str:
AppSettings.mod_data_dirs.pop(mod_type)
AppSettings.mod_data_dirs.pop(mod_type, None)
app.mod.update_mod_data_dirs()
result = True

# -- Set
if app.mod.check_mod_data_dir(Path(directory_str), int(mod_type)):
if app.mod.check_mod_data_dir(Path(directory_str), mod_type):
AppSettings.mod_data_dirs[mod_type] = str(WindowsPath(directory_str))
AppSettings.save()
result = True
Expand Down
2 changes: 2 additions & 0 deletions app/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def load(cls) -> bool:
logging.error('Could not load application settings! %s', e)
return False

# -- Convert str dict keys to int
AppSettings.mod_data_dirs = {int(k): v for k, v in AppSettings.mod_data_dirs.items()}
return True

@classmethod
Expand Down
7 changes: 4 additions & 3 deletions src/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,16 @@ export default {
},
setBusy: function (busy) { this.isBusy = busy},
getModDir: async function (modType = 0) {
const r = await window.eel.get_mod_dir(Number(modType))()
const r = await window.eel.get_mod_dir(modType)()
if (r !== undefined) { this.modDataDirs[modType] = r }
},
resetModDir: async function(modType = 0) {
modType = Number(modType)
this.modDirInput = ''
await this.setModDir(modType)
},
setModDir: async function (modType) {
const r = await getEelJsonObject(window.eel.set_mod_dir(this.modDirInput, Number(modType))())
const r = await getEelJsonObject(window.eel.set_mod_dir(this.modDirInput, modType)())
if (r !== undefined && r.result) {
await this.getModDir(modType)
Expand All @@ -183,7 +184,7 @@ export default {
this.$eventHub.$on('make-toast', this.makeToast)
this.$eventHub.$on('set-busy', this.setBusy)
for (const modType in this.modTypes) {
await this.getModDir(modType)
await this.getModDir(Number(modType))
}
},
beforeDestroy() {
Expand Down

0 comments on commit dc5da6f

Please sign in to comment.