Make message links to deleted profiles display 404: (fixes 11020) (#12229)

* Make links to deleted profiles display 404

* Implement some requested changes

- remove comments
- remove 'await'
- rename error -> 404error
- remove catch block -> just check for 404

* Fix bug: Logged in user profile showing 404

- Initiallty logged in user will display fine
- This bug only appeared after you view a deleted users modal

* Remove 'user.active' attribute

- add change to data():
- user: undefined -> user: {}

* Shorten showMemberModal()

- Remove unused fetch profile data
- Remove unnecessary conditional

* Change user initial value to null

- Add userLoaded to data
This commit is contained in:
jacobguinther
2020-06-27 08:53:55 -06:00
committed by GitHub
parent 083417fe48
commit e42518f427
3 changed files with 114 additions and 116 deletions

View File

@@ -310,27 +310,7 @@ export default {
return false;
},
async showMemberModal (memberId) {
let profile = this.cachedProfileData[memberId];
if (!profile._id) {
const result = await this.$store.dispatch('members:fetchMember', { memberId });
if (result.response && result.response.status === 404) {
this.$store.dispatch('snackbars:add', {
title: 'Habitica',
text: this.$t('messageDeletedUser'),
type: 'error',
timeout: false,
});
} else {
this.cachedProfileData[memberId] = result.data.data;
profile = result.data.data;
}
}
// Open the modal only if the data is available
if (profile && !profile.rejected) {
this.$router.push({ name: 'userProfile', params: { userId: profile._id } });
}
this.$router.push({ name: 'userProfile', params: { userId: memberId } });
},
itemWasMounted: debounce(function itemWasMounted () {
if (this.handleScrollBack) {