diff --git a/website/client/components/chat/chatMessages.vue b/website/client/components/chat/chatMessages.vue index 40532a5e0c..edf6526d9c 100644 --- a/website/client/components/chat/chatMessages.vue +++ b/website/client/components/chat/chatMessages.vue @@ -472,10 +472,15 @@ export default { }); }, showMemberModal (memberId) { - // @TODO move to action or anyway move from here because it's super duplicate - this.$store.state.profileUser = this.cachedProfileData[memberId]; - this.$store.state.profileOptions.startingPage = 'profile'; - this.$root.$emit('show::modal', 'profile'); + const profile = this.cachedProfileData[memberId]; + + // Open the modal only if the data is available + if (profile && !profile.rejected) { + // @TODO move to action or anyway move from here because it's super duplicate + this.$store.state.profileUser = profile; + this.$store.state.profileOptions.startingPage = 'profile'; + this.$root.$emit('show::modal', 'profile'); + } }, }, }; diff --git a/website/client/libs/notifications.js b/website/client/libs/notifications.js index c9fd12db80..b39c4bff21 100644 --- a/website/client/libs/notifications.js +++ b/website/client/libs/notifications.js @@ -30,4 +30,23 @@ export function getDropClass ({type, key}) { } return dropClass; +} + +export function getSign (number) { + let sign = '+'; + + if (number && number < 0) { + sign = '-'; + } + + return sign; +} + +export function round (number, nDigits) { + return Math.abs(number.toFixed(nDigits || 1)); +} + +export function getXPMessage (val) { + if (val < -50) return; // don't show when they level up (resetting their exp) + return `${getSign(val)} ${round(val)}`; } \ No newline at end of file diff --git a/website/client/mixins/notifications.js b/website/client/mixins/notifications.js index d405076ddb..a3b712cca3 100644 --- a/website/client/mixins/notifications.js +++ b/website/client/mixins/notifications.js @@ -1,6 +1,6 @@ import habiticaMarkdown from 'habitica-markdown'; import { mapState } from 'client/libs/store'; -import { getDropClass } from 'client/libs/notifications'; +import { getDropClass, getXPMessage, getSign, round } from 'client/libs/notifications'; export default { computed: { @@ -22,8 +22,7 @@ export default { this.notify(this.$t(type, { val }), 'success'); }, exp (val) { - if (val < -50) return; // don't show when they level up (resetting their exp) - let message = `${this.sign(val)} ${this.round(val)}`; + let message = getXPMessage(val); this.notify(message, 'xp', 'glyphicon glyphicon-star', this.sign(val)); }, error (error) { @@ -60,14 +59,10 @@ export default { this.notify(val, 'info', null, null, onClick); }, sign (number) { - let sign = '+'; - if (number && number < 0) { - sign = '-'; - } - return sign; + return getSign(number); }, round (number, nDigits) { - return Math.abs(number.toFixed(nDigits || 1)); + return round(number, nDigits); }, notify (html, type, icon, sign) { this.notifications.push({ diff --git a/website/client/store/actions/shops.js b/website/client/store/actions/shops.js index e44627a4d3..b44597efe8 100644 --- a/website/client/store/actions/shops.js +++ b/website/client/store/actions/shops.js @@ -81,16 +81,18 @@ export async function genericPurchase (store, params) { let result = await axios.post('/api/v3/user/buy-armoire'); buyResult = result.data.data; - // @TODO: We might need to abstract notifications to library rather than mixin if (buyResult) { const resData = buyResult; const item = resData.armoire; + const isExperience = item.type === 'experience'; + + // @TODO: We might need to abstract notifications to library rather than mixin store.state.notificationStore.push({ title: '', - text: item.dropText, - type: item.type === 'experience' ? 'xp' : 'drop', - icon: item.type === 'experience' ? null : getDropClass({type: item.type, key: item.dropKey}), + text: isExperience ? item.value : item.dropText, + type: isExperience ? 'xp' : 'drop', + icon: isExperience ? null : getDropClass({type: item.type, key: item.dropKey}), timeout: true, }); }