Skip to content

Commit

Permalink
fix: profile deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Sep 1, 2019
1 parent 003d10f commit 9862d49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/main/store/modules/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ const mod = {
},

async deleteProfile(context, id = context.state.id) {
if (typeof id !== 'string') {
console.error(`Invalid contract! Should pass profile id to delete profile. Get ${id}`);
return;
}
if (context.state.id === id) {
const allIds = Object.keys(context.state.all);
if (allIds.length === 1) {
Expand All @@ -408,7 +412,10 @@ const mod = {
}
}
context.commit('removeProfile', id);
await fs.remove(context.rootGetters.path('profiles', id));
const profileDir = context.rootGetters.path('profiles', id);
if (await fs.exists(profileDir)) {
await fs.remove(profileDir);
}
},


Expand Down
9 changes: 8 additions & 1 deletion src/renderer/windows/main/ProfilesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,14 @@ export default {
});
},
doDelete() {
this.$repo.dispatch('deleteProfile', this.deletingProfile);
if (this.deletingProfile) {
this.$repo.dispatch('deleteProfile', this.deletingProfile.id)
.finally(() => {
this.isDeletingProfile = false;
});
} else {
this.isDeletingProfile = false;
}
},
cancelDelete() {
this.isDeletingProfile = false;
Expand Down

0 comments on commit 9862d49

Please sign in to comment.