From cd8c2ff8a7f7868c1ad230244d286dc40d400c4e Mon Sep 17 00:00:00 2001 From: Vili Manninen Date: Tue, 21 May 2024 14:48:30 +0300 Subject: [PATCH] Fix selecting Default Profile after deleting a Profile --- .../profiles-modals/DeleteProfileModal.vue | 2 +- src/store/modules/ProfilesModule.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/profiles-modals/DeleteProfileModal.vue b/src/components/profiles-modals/DeleteProfileModal.vue index 467371005..4fd8abea3 100644 --- a/src/components/profiles-modals/DeleteProfileModal.vue +++ b/src/components/profiles-modals/DeleteProfileModal.vue @@ -23,7 +23,7 @@ export default class DeleteProfileModal extends Vue { try { await this.$store.dispatch('profiles/removeSelectedProfile'); } catch (e) { - const err = R2Error.fromThrownValue(e, 'Error whilst deleting profile with DeleteProfileModal'); + const err = R2Error.fromThrownValue(e, 'Error whilst deleting profile'); this.$store.commit('error/handleError', err); } this.closeDeleteProfileModal(); diff --git a/src/store/modules/ProfilesModule.ts b/src/store/modules/ProfilesModule.ts index 1786632d0..356e5b777 100644 --- a/src/store/modules/ProfilesModule.ts +++ b/src/store/modules/ProfilesModule.ts @@ -36,9 +36,16 @@ export const ProfilesModule = { throw R2Error.fromThrownValue(e, 'Error whilst deleting profile from disk'); } - if (profileName.toLowerCase() !== 'default') { - state.profileList = state.profileList.filter((p: string) => p !== profileName) - await dispatch('profile/updateActiveProfile', 'Default', { root: true }); + state.profileList = state.profileList.filter((p: string) => p !== profileName) + await dispatch('setSelectedProfile', { profileName: 'Default', prewarmCache: true }); + }, + + async setSelectedProfile({rootGetters, state, dispatch}, params: { profileName: string, prewarmCache: boolean }) { + await dispatch('profile/updateActiveProfile', params.profileName, { root: true }); + + if (params.prewarmCache) { + await dispatch('profile/updateModListFromFile', null, { root: true }); + await dispatch('tsMods/prewarmCache', null, { root: true }); } }, },