fix(profile): revert state on error
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user