fix(profile): revert state on error

This commit is contained in:
SabreCat
2023-12-22 17:24:45 -06:00
parent 6aa6278727
commit 83bcd07e20
@@ -1222,9 +1222,10 @@ export default {
const { nextRewardAt } = currentLoginDay;
return ((nextRewardAt - previousRewardDay));
},
save () {
async save () {
const values = {};
const edits = cloneDeep(this.editingProfile);
const oldProfile = cloneDeep(this.user.profile);
each(edits, (value, key) => {
// Using toString because we need to compare two arrays (websites)
@@ -1235,7 +1236,12 @@ export default {
}
});
this.$store.dispatch('user:set', values);
await this.$store.dispatch('user:set', values).catch(() => {
this.user.profile = oldProfile;
this.editingProfile.name = this.user.profile.name;
this.editingProfile.imageUrl = this.user.profile.imageUrl;
this.editingProfile.blurb = this.user.profile.blurb;
});
this.editing = false;
},