diff --git a/website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css b/website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css index 23e6151234..7fd10f4cfb 100644 --- a/website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css +++ b/website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css @@ -1,133 +1,78 @@ .promo_armoire_backgrounds_201910 { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: 0px -190px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: 0px -389px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 423px; height: 147px; } .promo_costume_achievement { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: -734px 0px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: -698px -426px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 144px; height: 156px; } .promo_desert_pet_achievements { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: 0px -634px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: -891px -296px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 204px; height: 102px; } .promo_fall_festival_2018 { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: -361px 0px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: 0px -208px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 372px; height: 180px; } .promo_fall_festival_2019 { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: 0px 0px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: -337px 0px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 360px; height: 189px; } .promo_fall_skins { - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); + background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: 0px 0px; width: 336px; height: 207px; } .customize-option.promo_fall_skins { - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); + background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: -25px -15px; width: 60px; height: 60px; } .promo_mystery_201909 { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: -424px -190px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: -698px -148px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 282px; height: 147px; } .promo_seasonal_shop_fall { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: -424px -486px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: -843px -426px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 162px; height: 138px; } .promo_shadow_spooky_potions { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: 0px -338px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: -698px 0px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css + background-position: 0px -537px; width: 423px; height: 147px; } .promo_spooky_sparkles { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: 0px -486px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: 0px -537px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css + background-position: -698px 0px; width: 423px; height: 147px; } .promo_take_this { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: -734px -157px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: -981px -148px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 96px; height: 69px; } .scene_strength { -<<<<<<< HEAD:website/client/src/assets/css/sprites/spritesmith-largeSprites-0.css background-image: url('~@/assets/images/sprites/spritesmith-largeSprites-0.png'); - background-position: -424px -338px; -======= - background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-position: -698px -296px; ->>>>>>> develop:website/client/assets/css/sprites/spritesmith-largeSprites-0.css width: 192px; height: 129px; } diff --git a/website/client/src/assets/images/sprites/spritesmith-largeSprites-0.png b/website/client/src/assets/images/sprites/spritesmith-largeSprites-0.png index d4c374f17d..35781b0606 100644 Binary files a/website/client/src/assets/images/sprites/spritesmith-largeSprites-0.png and b/website/client/src/assets/images/sprites/spritesmith-largeSprites-0.png differ diff --git a/website/client/src/components/achievements/chooseClass.vue b/website/client/src/components/achievements/chooseClass.vue index 9d106f4916..67107d2f96 100644 --- a/website/client/src/components/achievements/chooseClass.vue +++ b/website/client/src/components/achievements/chooseClass.vue @@ -130,12 +130,6 @@ export default { components: { Avatar, }, - computed: { - ...mapState({ - user: 'user.data', - classes: 'content.classes', - }), - }, directives: { markdown: markdownDirective, }, @@ -150,12 +144,18 @@ export default { selectedClass: 'warrior', }; }, + computed: { + ...mapState({ + user: 'user.data', + classes: 'content.classes', + }), + }, methods: { close () { this.$root.$emit('bv::hide::modal', 'choose-class'); }, clickSelectClass (heroClass) { - if (this.user.flags.classSelected && !confirm(this.$t('changeClassConfirmCost'))) return; + if (this.user.flags.classSelected && !window.confirm(this.$t('changeClassConfirmCost'))) return; this.$store.dispatch('user:changeClass', { query: { class: heroClass } }); }, clickDisableClasses () { @@ -196,6 +196,8 @@ export default { if (selectedClass === heroClass) { return 'selection-box'; } + + return null; }, }, }; diff --git a/website/client/src/components/achievements/justAddWater.vue b/website/client/src/components/achievements/justAddWater.vue index b881c2e369..ad7a1e1d08 100644 --- a/website/client/src/components/achievements/justAddWater.vue +++ b/website/client/src/components/achievements/justAddWater.vue @@ -29,14 +29,14 @@ export default { achievementFooter, achievementAvatar, }, - computed: { - ...mapState({ user: 'user.data' }), - }, data () { return { title: `${this.$t('modalAchievement')} ${this.$t('achievementJustAddWater')}`, }; }, + computed: { + ...mapState({ user: 'user.data' }), + }, methods: { close () { this.$root.$emit('bv::hide::modal', 'just-add-water'); diff --git a/website/client/src/components/achievements/levelUp.vue b/website/client/src/components/achievements/levelUp.vue index 90956723d4..70226b57c1 100644 --- a/website/client/src/components/achievements/levelUp.vue +++ b/website/client/src/components/achievements/levelUp.vue @@ -143,15 +143,15 @@ export default { facebookLink: `https://www.facebook.com/sharer/sharer.php?text=${tweet}&u=${BASE_URL}/social/level-up`, }; }, - mounted () { - this.loadWidgets(); - }, computed: { ...mapState({ user: 'user.data' }), showAllocation () { return this.$store.getters['members:hasClass'](this.user) && !this.user.preferences.automaticAllocation; }, }, + mounted () { + this.loadWidgets(); + }, methods: { close () { this.$root.$emit('bv::hide::modal', 'level-up'); @@ -160,7 +160,8 @@ export default { // @TODO: }, changeLevelupSuppress () { - // @TODO: dispatch set({"preferences.suppressModals.levelUp": user.preferences.suppressModals.levelUp?true: false}) + // @TODO: dispatch set({"preferences.suppressModals.levelUp": + // user.preferences.suppressModals.levelUp?true: false}) }, }, }; diff --git a/website/client/src/components/achievements/login-incentives.vue b/website/client/src/components/achievements/login-incentives.vue index a7d5f45e47..6c2ba748b2 100644 --- a/website/client/src/components/achievements/login-incentives.vue +++ b/website/client/src/components/achievements/login-incentives.vue @@ -70,7 +70,7 @@ export default { user: 'user.data', }), nextReward () { - if (!this.loginIncentives[this.user.loginIncentives]) return; + if (!this.loginIncentives[this.user.loginIncentives]) return null; const nextRewardKey = this.loginIncentives[this.user.loginIncentives].nextRewardAt; const nextReward = this.loginIncentives[nextRewardKey]; return nextReward; diff --git a/website/client/src/components/achievements/lostMasterclasser.vue b/website/client/src/components/achievements/lostMasterclasser.vue index b067c13693..8ebe1d6eb4 100644 --- a/website/client/src/components/achievements/lostMasterclasser.vue +++ b/website/client/src/components/achievements/lostMasterclasser.vue @@ -29,14 +29,14 @@ export default { achievementFooter, achievementAvatar, }, - computed: { - ...mapState({ user: 'user.data' }), - }, data () { return { title: `${this.$t('modalAchievement')} ${this.$t('achievementLostMasterclasser')}`, }; }, + computed: { + ...mapState({ user: 'user.data' }), + }, methods: { close () { this.$root.$emit('bv::hide::modal', 'lost-masterclasser'); diff --git a/website/client/src/components/achievements/mindOverMatter.vue b/website/client/src/components/achievements/mindOverMatter.vue index d25f1129cf..80ad2266ff 100644 --- a/website/client/src/components/achievements/mindOverMatter.vue +++ b/website/client/src/components/achievements/mindOverMatter.vue @@ -29,14 +29,14 @@ export default { achievementFooter, achievementAvatar, }, - computed: { - ...mapState({ user: 'user.data' }), - }, data () { return { title: `${this.$t('modalAchievement')} ${this.$t('achievementMindOverMatter')}`, }; }, + computed: { + ...mapState({ user: 'user.data' }), + }, methods: { close () { this.$root.$emit('bv::hide::modal', 'mind-over-matter'); diff --git a/website/client/src/components/achievements/wonChallenge.vue b/website/client/src/components/achievements/wonChallenge.vue index 3390579edf..aefc16050d 100644 --- a/website/client/src/components/achievements/wonChallenge.vue +++ b/website/client/src/components/achievements/wonChallenge.vue @@ -48,15 +48,15 @@ export default { directives: { markdown: markdownDirective, }, - computed: { - ...mapState({ user: 'user.data' }), - }, data () { const tweet = this.$t('wonChallengeShare'); return { tweet, }; }, + computed: { + ...mapState({ user: 'user.data' }), + }, methods: { close () { this.$root.$emit('bv::hide::modal', 'won-challenge'); diff --git a/website/client/src/components/appFooter.vue b/website/client/src/components/appFooter.vue index fe5dbd0209..4b5560bde8 100644 --- a/website/client/src/components/appFooter.vue +++ b/website/client/src/components/appFooter.vue @@ -299,7 +299,7 @@ export default { ...mapState(['isUserLoaded']), getDataDisplayToolUrl () { const base = 'https://oldgods.net/habitrpg/habitrpg_user_data_display.html'; - if (!this.user) return; + if (!this.user) return null; return `${base}?uuid=${this.user._id}`; }, @@ -357,7 +357,7 @@ export default { // @TODO: Name these variables better let exp = 0; const five = 10 * this.user.stats.lvl; - const four = Math.pow(this.user.stats.lvl, 2) * 0.25; + const four = (this.user.stats.lvl ** 2) * 0.25; const three = four + five + 139.75; const two = three / 10; const one = Math.round(two) * 10; @@ -381,7 +381,8 @@ export default { async makeAdmin () { await axios.post('/api/v4/debug/make-admin'); - // @TODO: Notification.text('You are now an admin! Go to the Hall of Heroes to change your contributor level.'); + // @TODO: Notification.text('You are now an admin! + // Go to the Hall of Heroes to change your contributor level.'); // @TODO: sync() }, openModifyInventoryModal () { diff --git a/website/client/src/components/auth/authForm.vue b/website/client/src/components/auth/authForm.vue index fd9e9d8871..af9c53473b 100644 --- a/website/client/src/components/auth/authForm.vue +++ b/website/client/src/components/auth/authForm.vue @@ -184,12 +184,12 @@ export default { }, async register () { if (!this.email) { - alert(this.$t('missingEmail')); + window.alert(this.$t('missingEmail')); return; } if (this.password !== this.passwordConfirm) { - alert(this.$t('passwordConfirmationMatch')); + window.alert(this.$t('passwordConfirmationMatch')); return; } @@ -205,7 +205,7 @@ export default { } catch (e) { if (e.response.data.data && e.response.data.data.errors) { const message = e.response.data.data.errors.map(error => `${error.message}\n`); - alert(message); + window.alert(message); } } }, diff --git a/website/client/src/components/auth/logout.vue b/website/client/src/components/auth/logout.vue index c29116c474..5c0661cc7e 100644 --- a/website/client/src/components/auth/logout.vue +++ b/website/client/src/components/auth/logout.vue @@ -6,7 +6,7 @@ export default { }, methods: { async logout () { - return await this.$store.dispatch('auth:logout'); + return this.$store.dispatch('auth:logout'); }, }, }; diff --git a/website/client/src/components/auth/registerLoginReset.vue b/website/client/src/components/auth/registerLoginReset.vue index 2c241f157d..956cc682c4 100644 --- a/website/client/src/components/auth/registerLoginReset.vue +++ b/website/client/src/components/auth/registerLoginReset.vue @@ -372,13 +372,13 @@ export default { const { code } = query; const hasError = query.hasError === 'true'; if (hasError) { - alert(query.message); + window.alert(query.message); this.$router.push({ name: 'login' }); return; } if (!code) { - alert(this.$t('invalidPasswordResetCode')); + window.alert(this.$t('invalidPasswordResetCode')); this.$router.push({ name: 'login' }); return; } @@ -419,18 +419,19 @@ export default { async register () { // @TODO do not use alert if (!this.email) { - alert(this.$t('missingEmail')); + window.alert(this.$t('missingEmail')); return; } if (this.password !== this.passwordConfirm) { - alert(this.$t('passwordConfirmationMatch')); + window.alert(this.$t('passwordConfirmationMatch')); return; } // @TODO: implement langauge and invite accepting // var url = ApiUrl.get() + "/api/v4/user/auth/local/register"; - // if (location.search && location.search.indexOf('Invite=') !== -1) { // matches groupInvite and partyInvite + // if (location.search && location.search.indexOf('Invite=') !== -1) + // { // matches groupInvite and partyInvite // url += location.search; // } // @@ -457,7 +458,8 @@ export default { // @TODO do not reload entire page // problem is that app.vue created hook should be called again // after user is logged in / just signed up - // ALSO it's the only way to make sure language data is reloaded and correct for the logged in user + // ALSO it's the only way to make sure language data + // is reloaded and correct for the logged in user window.location.href = redirectTo; }, async login () { @@ -478,7 +480,8 @@ export default { // @TODO do not reload entire page // problem is that app.vue created hook should be called again // after user is logged in / just signed up - // ALSO it's the only way to make sure language data is reloaded and correct for the logged in user + // ALSO it's the only way to make sure language data + // is reloaded and correct for the logged in user window.location.href = redirectTo; }, // @TODO: Abstract hello in to action or lib @@ -509,7 +512,8 @@ export default { // @TODO do not reload entire page // problem is that app.vue created hook should be called again // after user is logged in / just signed up - // ALSO it's the only way to make sure language data is reloaded and correct for the logged in user + // ALSO it's the only way to make sure language data + // is reloaded and correct for the logged in user window.location.href = redirectTo; }, handleSubmit () { @@ -532,7 +536,7 @@ export default { }, async forgotPasswordLink () { if (!this.username) { - alert(this.$t('missingEmail')); + window.alert(this.$t('missingEmail')); return; } @@ -540,17 +544,17 @@ export default { email: this.username, }); - alert(this.$t('newPassSent')); + window.alert(this.$t('newPassSent')); }, async resetPasswordSetNewOneLink () { if (!this.password) { - alert(this.$t('missingNewPassword')); + window.alert(this.$t('missingNewPassword')); return; } if (this.password !== this.passwordConfirm) { // @TODO i18n and don't use alerts - alert(this.$t('passwordConfirmationMatch')); + window.alert(this.$t('passwordConfirmationMatch')); return; } @@ -561,7 +565,7 @@ export default { }); if (res.data.message) { - alert(res.data.message); + window.alert(res.data.message); } this.password = ''; diff --git a/website/client/src/components/avatarModal/extra-settings.vue b/website/client/src/components/avatarModal/extra-settings.vue index 356b7ce1c8..89a6566dec 100644 --- a/website/client/src/components/avatarModal/extra-settings.vue +++ b/website/client/src/components/avatarModal/extra-settings.vue @@ -134,7 +134,9 @@ export default { const newKey = `eyewear_special_${key}`; const option = {}; option.key = key; - option.active = this.user.preferences.costume ? this.user.items.gear.costume.eyewear === newKey : this.user.items.gear.equipped.eyewear === newKey; + option.active = this.user.preferences.costume + ? this.user.items.gear.costume.eyewear === newKey + : this.user.items.gear.equipped.eyewear === newKey; option.class = `eyewear_special_${key}`; option.click = () => { const type = this.user.preferences.costume ? 'costume' : 'equipped'; @@ -160,7 +162,9 @@ export default { const newKey = `headAccessory_special_${key}`; const option = {}; option.key = key; - option.active = this.user.preferences.costume ? this.user.items.gear.costume.headAccessory === newKey : this.user.items.gear.equipped.headAccessory === newKey; + option.active = this.user.preferences.costume + ? this.user.items.gear.costume.headAccessory === newKey + : this.user.items.gear.equipped.headAccessory === newKey; option.class = `headAccessory_special_${option.key} headband`; option.click = () => { const type = this.user.preferences.costume ? 'costume' : 'equipped'; @@ -205,7 +209,8 @@ export default { }, methods: { animalItems (category) { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now + // @TODO: For some resonse when I use $set on the + // user purchases object, this is not recomputed. Hack for now let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const keys = this.animalItemKeys[category]; const options = keys.map(key => { @@ -214,7 +219,9 @@ export default { const option = {}; option.key = key; - option.active = this.user.preferences.costume ? this.user.items.gear.costume[category] === newKey : this.user.items.gear.equipped[category] === newKey; + option.active = this.user.preferences.costume + ? this.user.items.gear.costume[category] === newKey + : this.user.items.gear.equipped[category] === newKey; option.class = `headAccessory_special_${option.key} ${category}`; if (category === 'back') { option.class = `icon_back_special_${option.key} back`; @@ -247,7 +254,8 @@ export default { return keys.join(','); }, animalItemsOwned (category) { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line let own = true; diff --git a/website/client/src/components/avatarModal/hair-settings.vue b/website/client/src/components/avatarModal/hair-settings.vue index 01f3bf2c93..b202cb25ae 100644 --- a/website/client/src/components/avatarModal/hair-settings.vue +++ b/website/client/src/components/avatarModal/hair-settings.vue @@ -112,11 +112,12 @@ export default { return freeHairColorKeys.map(s => this.mapKeysToFreeOption(s, 'hair', 'color')); }, seasonalHairColors () { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const seasonalHairColors = []; - for (const key in hairColorBySet) { + for (const key of Object.keys(hairColorBySet)) { const set = hairColorBySet[key]; const keys = set.map(item => item.key); @@ -143,22 +144,25 @@ export default { return seasonalHairColors; }, premiumHairColors () { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const keys = this.premiumHairColorKeys; const options = keys.map(key => this.mapKeysToOption(key, 'hair', 'color')); return options; }, baseHair2 () { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const keys = this.baseHair2Keys; const options = keys.map(key => this.mapKeysToOption(key, 'hair', 'base')); return options; }, baseHair3 () { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const keys = this.baseHair3Keys; const options = keys.map(key => { const option = this.mapKeysToOption(key, 'hair', 'base'); @@ -167,22 +171,25 @@ export default { return options; }, baseHair4 () { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const keys = this.baseHair4Keys; const options = keys.map(key => this.mapKeysToOption(key, 'hair', 'base')); return options; }, baseHair5 () { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const keys = this.baseHair5Keys; const options = keys.map(key => this.mapKeysToOption(key, 'hair', 'mustache')); return options; }, baseHair6 () { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const keys = this.baseHair6Keys; const options = keys.map(key => this.mapKeysToOption(key, 'hair', 'beard')); return options; @@ -259,11 +266,13 @@ export default { }, methods: { /** - * Allows you to find out whether you need the "Purchase All" button or not. If there are more than 2 unpurchased items, returns true, otherwise returns false. + * Allows you to find out whether you need the "Purchase All" button or not. + * If there are more than 2 unpurchased items, returns true, otherwise returns false. * @param {string} category - The selected category. * @param {string[]} keySets - The items keySets. * @param {string[]} [types] - The items types (subcategories). Optional. - * @returns {boolean} - Determines whether the "Purchase All" button is needed (true) or not (false). + * @returns {boolean} - Determines whether the "Purchase All" button + * is needed (true) or not (false). */ isPurchaseAllNeeded (category, keySets, types) { const purchasedItemsLengths = []; diff --git a/website/client/src/components/avatarModal/skin-settings.vue b/website/client/src/components/avatarModal/skin-settings.vue index d2b46536cd..ade49993d2 100644 --- a/website/client/src/components/avatarModal/skin-settings.vue +++ b/website/client/src/components/avatarModal/skin-settings.vue @@ -31,8 +31,8 @@ const skinsBySet = groupBy(appearance.skin, 'set.key'); const freeSkinKeys = skinsBySet[undefined].map(s => s.key); -// const specialSkinKeys = Object.keys(appearance.shirt).filter(k => appearance.shirt[k].price !== 0); - +// const specialSkinKeys = Object.keys(appearance.shirt) +// .filter(k => appearance.shirt[k].price !== 0); export default { components: { @@ -66,11 +66,12 @@ export default { return freeSkinKeys.map(s => this.mapKeysToFreeOption(s, 'skin')); }, seasonalSkins () { - // @TODO: For some resonse when I use $set on the user purchases object, this is not recomputed. Hack for now - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // @TODO: For some resonse when I use $set on the user purchases object, + // this is not recomputed. Hack for now + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const seasonalSkins = []; - for (const setKey in skinsBySet) { + for (const setKey of Object.keys(skinsBySet)) { const set = skinsBySet[setKey]; const keys = set.map(item => item.key); @@ -101,12 +102,5 @@ export default { mounted () { this.changeSubPage('color'); }, - methods: { - - }, }; - - diff --git a/website/client/src/components/challenges/challengeDetail.vue b/website/client/src/components/challenges/challengeDetail.vue index b9ed1e69cd..e141f60a4f 100644 --- a/website/client/src/components/challenges/challengeDetail.vue +++ b/website/client/src/components/challenges/challengeDetail.vue @@ -284,7 +284,8 @@ export default { }, async loadChallenge () { this.challenge = await this.$store.dispatch('challenges:getChallenge', { challengeId: this.searchId }); - this.members = await this.loadMembers({ challengeId: this.searchId, includeAllPublicFields: true }); + this.members = await this + .loadMembers({ challengeId: this.searchId, includeAllPublicFields: true }); const tasks = await this.$store.dispatch('tasks:getChallengeTasks', { challengeId: this.searchId }); this.tasksByType = { habit: [], diff --git a/website/client/src/components/challenges/challengeModal.vue b/website/client/src/components/challenges/challengeModal.vue index c6f1bcc437..8a5d07d6e6 100644 --- a/website/client/src/components/challenges/challengeModal.vue +++ b/website/client/src/components/challenges/challengeModal.vue @@ -233,35 +233,6 @@ export default { groups: [], }; }, - watch: { - user () { - if (!this.challenge) this.workingChallenge.leader = this.user._id; - }, - challenge () { - this.setUpWorkingChallenge(); - }, - cloning () { - this.setUpWorkingChallenge(); - }, - }, - mounted () { - this.$root.$on('habitica:clone-challenge', data => { - if (!data.challenge) return; - this.cloning = true; - this.cloningChallengeId = data.challenge._id; - this.$store.state.challengeOptions.workingChallenge = { ...this.$store.state.challengeOptions.workingChallenge, ...data.challenge }; - this.$root.$emit('bv::show::modal', 'challenge-modal'); - }); - this.$root.$on('habitica:update-challenge', data => { - if (!data.challenge) return; - this.cloning = false; - this.$store.state.challengeOptions.workingChallenge = { ...this.$store.state.challengeOptions.workingChallenge, ...data.challenge }; - this.$root.$emit('bv::show::modal', 'challenge-modal'); - }); - }, - beforeDestroy () { - this.$root.$off('habitica:clone-challenge'); - }, computed: { ...mapState({ user: 'user.data' }), creating () { @@ -274,7 +245,9 @@ export default { return this.$t('editingChallenge'); }, charactersRemaining () { - const currentLength = this.workingChallenge.summary ? this.workingChallenge.summary.length : 0; + const currentLength = this.workingChallenge.summary + ? this.workingChallenge.summary.length + : 0; return MAX_SUMMARY_SIZE_FOR_CHALLENGES - currentLength; }, maxPrize () { @@ -312,6 +285,41 @@ export default { return this.$store.state.challengeOptions.workingChallenge; }, }, + watch: { + user () { + if (!this.challenge) this.workingChallenge.leader = this.user._id; + }, + challenge () { + this.setUpWorkingChallenge(); + }, + cloning () { + this.setUpWorkingChallenge(); + }, + }, + mounted () { + this.$root.$on('habitica:clone-challenge', data => { + if (!data.challenge) return; + this.cloning = true; + this.cloningChallengeId = data.challenge._id; + this.$store.state.challengeOptions.workingChallenge = { + ...this.$store.state.challengeOptions.workingChallenge, + ...data.challenge, + }; + this.$root.$emit('bv::show::modal', 'challenge-modal'); + }); + this.$root.$on('habitica:update-challenge', data => { + if (!data.challenge) return; + this.cloning = false; + this.$store.state.challengeOptions.workingChallenge = { + ...this.$store.state.challengeOptions.workingChallenge, + ...data.challenge, + }; + this.$root.$emit('bv::show::modal', 'challenge-modal'); + }); + }, + beforeDestroy () { + this.$root.$off('habitica:clone-challenge'); + }, methods: { async shown () { this.groups = await this.$store.dispatch('guilds:getMyGuilds'); @@ -378,7 +386,10 @@ export default { }, async createChallenge () { this.loading = true; - // @TODO: improve error handling, add it to updateChallenge, make errors translatable. Suggestion: `<% fieldName %> is required` where possible, where `fieldName` is inserted as the translatable string that's used for the field header. + // @TODO: improve error handling, add it to updateChallenge, + // make errors translatable. Suggestion: `<% fieldName %> + // is required` where possible, where `fieldName` is inserted + // as the translatable string that's used for the field header. const errors = []; if (!this.workingChallenge.name) errors.push(this.$t('nameRequired')); @@ -390,7 +401,7 @@ export default { if (!this.workingChallenge.categories || this.workingChallenge.categories.length === 0) errors.push(this.$t('categoiresRequired')); if (errors.length > 0) { - alert(errors.join('\n')); + window.alert(errors.join('\n')); this.loading = false; return; } @@ -425,9 +436,14 @@ export default { // @TODO: Share with server const prizeCost = this.workingChallenge.prize / 4; - const challengeGroupLeader = challengeGroup.leader && challengeGroup.leader._id ? challengeGroup.leader._id : challengeGroup.leader; + const challengeGroupLeader = challengeGroup.leader && challengeGroup.leader._id + ? challengeGroup.leader._id + : challengeGroup.leader; const userIsLeader = challengeGroupLeader === this.user._id; - if (challengeGroup && userIsLeader && challengeGroup.balance > 0 && challengeGroup.balance >= prizeCost) { + if ( + challengeGroup && userIsLeader + && challengeGroup.balance > 0 && challengeGroup.balance >= prizeCost + ) { // Group pays for all of prize } else if (challengeGroup && userIsLeader && challengeGroup.balance > 0) { // User pays remainder of prize cost after group diff --git a/website/client/src/components/challenges/closeChallengeModal.vue b/website/client/src/components/challenges/closeChallengeModal.vue index 76d97a1379..0f065b86bc 100644 --- a/website/client/src/components/challenges/closeChallengeModal.vue +++ b/website/client/src/components/challenges/closeChallengeModal.vue @@ -101,7 +101,7 @@ export default { this.$router.push('/challenges/myChallenges'); }, async deleteChallenge () { - if (!confirm('Are you sure you want to delete this challenge?')) return; + if (!window.confirm('Are you sure you want to delete this challenge?')) return; this.challenge = await this.$store.dispatch('challenges:deleteChallenge', { challengeId: this.challengeId, prize: this.prize, diff --git a/website/client/src/components/challenges/findChallenges.vue b/website/client/src/components/challenges/findChallenges.vue index 893dad43c5..b2d9d00c99 100644 --- a/website/client/src/components/challenges/findChallenges.vue +++ b/website/client/src/components/challenges/findChallenges.vue @@ -122,15 +122,15 @@ export default { page: 0, }; }, - mounted () { - this.loadChallenges(); - }, computed: { ...mapState({ user: 'user.data' }), filteredChallenges () { return this.challenges; }, }, + mounted () { + this.loadChallenges(); + }, methods: { updateSearch (eventData) { this.search = eventData.searchTerm; @@ -156,7 +156,7 @@ export default { let owned = ''; // @TODO: we skip ownership === 2 because it is the same as === 0 right now if (this.filters.ownership && this.filters.ownership.length === 1) { - owned = this.filters.ownership[0]; + [owned] = this.filters.ownership; } const challenges = await this.$store.dispatch('challenges:getUserChallenges', { diff --git a/website/client/src/components/challenges/groupChallenges.vue b/website/client/src/components/challenges/groupChallenges.vue index 0deb5816e7..95dcdc74b6 100644 --- a/website/client/src/components/challenges/groupChallenges.vue +++ b/website/client/src/components/challenges/groupChallenges.vue @@ -50,10 +50,10 @@ export default { challengeModal, challengeItem, }, - props: ['groupId'], - computed: { - ...mapState({ user: 'user.data' }), + directives: { + markdown: markdownDirective, }, + props: ['groupId'], data () { return { challenges: [], @@ -63,8 +63,8 @@ export default { groupIdForChallenges: '', }; }, - directives: { - markdown: markdownDirective, + computed: { + ...mapState({ user: 'user.data' }), }, watch: { async groupId () { diff --git a/website/client/src/components/challenges/myChallenges.vue b/website/client/src/components/challenges/myChallenges.vue index ad974d3e65..42760beef5 100644 --- a/website/client/src/components/challenges/myChallenges.vue +++ b/website/client/src/components/challenges/myChallenges.vue @@ -137,9 +137,6 @@ export default { page: 0, }; }, - mounted () { - this.loadChallenges(); - }, computed: { ...mapState({ user: 'user.data' }), filteredChallenges () { @@ -162,6 +159,9 @@ export default { }); }, }, + mounted () { + this.loadChallenges(); + }, methods: { updateSearch (eventData) { this.search = eventData.searchTerm; @@ -188,7 +188,7 @@ export default { let owned = ''; // @TODO: we skip ownership === 2 because it is the same as === 0 right now if (this.filters.ownership && this.filters.ownership.length === 1) { - owned = this.filters.ownership[0]; + [owned] = this.filters.ownership; } const challenges = await this.$store.dispatch('challenges:getUserChallenges', { diff --git a/website/client/src/components/chat/autoComplete.vue b/website/client/src/components/chat/autoComplete.vue index d0df214cb1..b830b76e9a 100644 --- a/website/client/src/components/chat/autoComplete.vue +++ b/website/client/src/components/chat/autoComplete.vue @@ -111,10 +111,12 @@ export default { searchResults () { if (!this.searchActive) return []; if (!this.atRegex.exec(this.text)) return []; - this.currentSearch = this.atRegex.exec(this.text)[0]; // eslint-disable-line vue/no-side-effects-in-computed-properties - this.currentSearch = this.currentSearch.substring(1, this.currentSearch.length); // eslint-disable-line vue/no-side-effects-in-computed-properties + this.currentSearch = this.atRegex.exec(this.text)[0]; // eslint-disable-line vue/no-side-effects-in-computed-properties, max-len, prefer-destructuring + this.currentSearch = this.currentSearch.substring(1, this.currentSearch.length); // eslint-disable-line vue/no-side-effects-in-computed-properties, max-len - return this.tmpSelections.filter(option => option.displayName.toLowerCase().indexOf(this.currentSearch.toLowerCase()) !== -1 || option.username && option.username.toLowerCase().indexOf(this.currentSearch.toLowerCase()) !== -1).slice(0, 4); + return this.tmpSelections + .filter(option => option.displayName.toLowerCase().indexOf(this.currentSearch.toLowerCase()) !== -1 || option.username && option.username.toLowerCase().indexOf(this.currentSearch.toLowerCase()) !== -1) + .slice(0, 4); }, }, @@ -153,7 +155,7 @@ export default { }, grabUserNames () { const usersThatMessage = groupBy(this.chat, 'user'); - for (const userKey in usersThatMessage) { + for (const userKey of Object.keys(usersThatMessage)) { const systemMessage = userKey === 'undefined'; if (!systemMessage && this.tmpSelections.indexOf(userKey) === -1) { this.tmpSelections.push({ diff --git a/website/client/src/components/chat/chatCard.vue b/website/client/src/components/chat/chatCard.vue index edc52ae889..75fd43fc29 100644 --- a/website/client/src/components/chat/chatCard.vue +++ b/website/client/src/components/chat/chatCard.vue @@ -176,7 +176,7 @@ export default { const message = this.msg; const { user } = this; - if (message.hasOwnProperty('highlight')) return message.highlight; + if (message.highlight) return message.highlight; message.highlight = false; const messageText = message.text.toLowerCase(); @@ -201,14 +201,14 @@ export default { if (!message.likes) return 0; let likeCount = 0; - for (const key in message.likes) { + for (const key of Object.keys(message.likes)) { const like = message.likes[key]; if (like) likeCount += 1; } return likeCount; }, isMessageReported () { - return this.msg.flags && this.msg.flags[this.user.id] || this.reported; + return (this.msg.flags && this.msg.flags[this.user.id]) || this.reported; }, flagCountDescription () { if (!this.msg.flagCount) return ''; @@ -242,6 +242,7 @@ export default { }, likeTooltip (likedStatus) { if (!likedStatus) return this.$t('like'); + return null; }, copyAsTodo (message) { this.$root.$emit('habitica::copy-as-todo', message); @@ -261,7 +262,7 @@ export default { }); }, async remove () { - if (!confirm(this.$t('areYouSureDeleteMessage'))) return; + if (!window.confirm(this.$t('areYouSureDeleteMessage'))) return; const message = this.msg; this.$emit('message-removed', message); @@ -280,7 +281,7 @@ export default { return highlightUsers(text, this.user.auth.local.username, this.user.profile.name); }, parseMarkdown (text) { - if (!text) return; + if (!text) return null; return habiticaMarkdown.render(String(text)); }, }, diff --git a/website/client/src/components/chat/chatMessages.vue b/website/client/src/components/chat/chatMessages.vue index e15a930949..0b59da5d15 100644 --- a/website/client/src/components/chat/chatMessages.vue +++ b/website/client/src/components/chat/chatMessages.vue @@ -178,15 +178,6 @@ export default { lastOffset: -1, }; }, - mounted () { - this.loadProfileCache(); - }, - created () { - window.addEventListener('scroll', this.handleScroll); - }, - destroyed () { - window.removeEventListener('scroll', this.handleScroll); - }, computed: { ...mapState({ user: 'user.data' }), // @TODO: We need a different lazy load mechnism. @@ -196,6 +187,15 @@ export default { return this.chat; }, }, + mounted () { + this.loadProfileCache(); + }, + created () { + window.addEventListener('scroll', this.handleScroll); + }, + destroyed () { + window.removeEventListener('scroll', this.handleScroll); + }, methods: { handleScroll () { this.loadProfileCache(window.scrollY / 1000); @@ -231,7 +231,10 @@ export default { // @TODO: write an explination // @TODO: Remove this after enough messages are cached - if (!noProfilesLoaded && screenPosition && Math.floor(screenPosition) + 1 > this.currentProfileLoadedEnd / 10) { + if ( + !noProfilesLoaded + && screenPosition && Math.floor(screenPosition) + 1 > this.currentProfileLoadedEnd / 10 + ) { this.currentProfileLoadedEnd = 10 * (Math.floor(screenPosition) + 1); } else if (!noProfilesLoaded && screenPosition) { return; @@ -255,7 +258,8 @@ export default { const results = await Promise.all(promises); results.forEach(result => { - // We could not load the user. Maybe they were deleted. So, let's cache empty so we don't try again + // We could not load the user. Maybe they were deleted. + // So, let's cache empty so we don't try again if (!result || !result.data || result.status >= 400) { return; } @@ -287,15 +291,16 @@ export default { if (!profile._id) { const result = await this.$store.dispatch('members:fetchMember', { memberId }); if (result.response && result.response.status === 404) { - return this.$store.dispatch('snackbars:add', { + 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; } - this.cachedProfileData[memberId] = result.data.data; - profile = result.data.data; } // Open the modal only if the data is available diff --git a/website/client/src/components/chat/reportFlagModal.vue b/website/client/src/components/chat/reportFlagModal.vue index 239ac8f567..0f7478995b 100644 --- a/website/client/src/components/chat/reportFlagModal.vue +++ b/website/client/src/components/chat/reportFlagModal.vue @@ -70,17 +70,6 @@ export default { markdown: markdownDirective, }, mixins: [notifications], - computed: { - ...mapState({ user: 'user.data' }), - reportData () { - let reportMessage = this.abuseObject.user; - const isSystemMessage = this.abuseObject.uuid === 'system'; - if (isSystemMessage) reportMessage = this.$t('systemMessage'); - return { - name: `${reportMessage}`, - }; - }, - }, data () { const abuseFlagModalBody = { firstLinkStart: '', @@ -95,6 +84,17 @@ export default { reportComment: '', }; }, + computed: { + ...mapState({ user: 'user.data' }), + reportData () { + let reportMessage = this.abuseObject.user; + const isSystemMessage = this.abuseObject.uuid === 'system'; + if (isSystemMessage) reportMessage = this.$t('systemMessage'); + return { + name: `${reportMessage}`, + }; + }, + }, created () { this.$root.$on('habitica::report-chat', this.handleReport); }, diff --git a/website/client/src/components/creatorIntro.vue b/website/client/src/components/creatorIntro.vue index 79f00d5335..bbbdefa4f1 100644 --- a/website/client/src/components/creatorIntro.vue +++ b/website/client/src/components/creatorIntro.vue @@ -787,23 +787,6 @@ export default { })), }; }, - watch: { - editing () { - if (this.editing) this.modalPage = 2; - }, - startingPage () { - if (!this.$store.state.avatarEditorOptions.startingPage) return; - this.activeTopPage = this.$store.state.avatarEditorOptions.startingPage; - this.activeSubPage = this.$store.state.avatarEditorOptions.subpage; - this.$store.state.avatarEditorOptions.startingPage = ''; - this.$store.state.avatarEditorOptions.subpage = ''; - }, - }, - mounted () { - if (this.editing) this.modalPage = 2; - // Buy modal is global, so we listen at root. I'd like to not - this.$root.$on('buyModal::boughtItem', this.backgroundPurchased); - }, computed: { ...mapState({ user: 'user.data' }), @@ -858,6 +841,23 @@ export default { return ownedBackgrounds; }, }, + watch: { + editing () { + if (this.editing) this.modalPage = 2; + }, + startingPage () { + if (!this.$store.state.avatarEditorOptions.startingPage) return; + this.activeTopPage = this.$store.state.avatarEditorOptions.startingPage; + this.activeSubPage = this.$store.state.avatarEditorOptions.subpage; + this.$store.state.avatarEditorOptions.startingPage = ''; + this.$store.state.avatarEditorOptions.subpage = ''; + }, + }, + mounted () { + if (this.editing) this.modalPage = 2; + // Buy modal is global, so we listen at root. I'd like to not + this.$root.$on('buyModal::boughtItem', this.backgroundPurchased); + }, methods: { purchase (type, key) { this.$store.dispatch('shops:purchase', { @@ -923,7 +923,7 @@ export default { ownsSet (type, set) { let setOwnedByUser = false; - for (let key in set) { + for (let key of Object.keys(set)) { const value = set[key]; if (type === 'background') key = value.key; if (this.user.purchased[type][key]) setOwnedByUser = true; @@ -933,7 +933,7 @@ export default { }, setKeys (type, _set) { return map(_set, (v, k) => { - if (type === 'background') k = v.key; + if (type === 'background') k = v.key; // eslint-disable-line no-param-reassign return `${type}.${k}`; }).join(','); }, diff --git a/website/client/src/components/group-plans/billing.vue b/website/client/src/components/group-plans/billing.vue index fe9b1fe7e2..af4f258720 100644 --- a/website/client/src/components/group-plans/billing.vue +++ b/website/client/src/components/group-plans/billing.vue @@ -46,6 +46,29 @@ export default { group: {}, }; }, + computed: { + ...mapState({ user: 'user.data' }), + isLeader () { + return this.user._id === this.group.leader._id; + }, + groupIsSubscribed () { + return this.group.purchased && this.group.purchased.plan + && this.group.purchased.plan.customerId; + }, + dateTerminated () { + if (!this.user.preferences || !this.user.preferences.dateFormat) { + return moment(this.group.purchased.plan.dateTerminated); + } + + return moment(this.group.purchased.plan.dateTerminated) + .format(this.user.preferences.dateFormat.toUpperCase()); + }, + purchasedGroupPlanPlanExtraMonths () { + return { + months: parseFloat(this.group.purchased.plan.extraMonths).toFixed(2), + }; + }, + }, async mounted () { await this.loadGroup(); @@ -61,24 +84,6 @@ export default { } } }, - computed: { - ...mapState({ user: 'user.data' }), - isLeader () { - return this.user._id === this.group.leader._id; - }, - groupIsSubscribed () { - return this.group.purchased && this.group.purchased.plan && this.group.purchased.plan.customerId; - }, - dateTerminated () { - if (!this.user.preferences || !this.user.preferences.dateFormat) return moment(this.group.purchased.plan.dateTerminated); - return moment(this.group.purchased.plan.dateTerminated).format(this.user.preferences.dateFormat.toUpperCase()); - }, - purchasedGroupPlanPlanExtraMonths () { - return { - months: parseFloat(this.group.purchased.plan.extraMonths).toFixed(2), - }; - }, - }, methods: { async loadGroup () { const group = await this.$store.dispatch('guilds:getGroup', { groupId: this.groupId }); diff --git a/website/client/src/components/group-plans/createGroupModalPages.vue b/website/client/src/components/group-plans/createGroupModalPages.vue index 98a5b2774e..4d15f5cd8e 100644 --- a/website/client/src/components/group-plans/createGroupModalPages.vue +++ b/website/client/src/components/group-plans/createGroupModalPages.vue @@ -150,6 +150,8 @@ export default { paymentData.type = 'subscription'; return paymentData; } + + return null; }, }, }; diff --git a/website/client/src/components/group-plans/taskInformation.vue b/website/client/src/components/group-plans/taskInformation.vue index 79d31b828d..0231d2fa37 100644 --- a/website/client/src/components/group-plans/taskInformation.vue +++ b/website/client/src/components/group-plans/taskInformation.vue @@ -126,22 +126,6 @@ export default { group: {}, }; }, - watch: { - // call again the method if the route changes (when this route is already active) - $route: 'load', - }, - beforeRouteUpdate (to, from, next) { - this.$set(this, 'searchId', to.params.groupId); - next(); - }, - mounted () { - if (!this.searchId) this.searchId = this.groupId; - this.load(); - - if (this.$route.query.showGroupOverview) { - this.$root.$emit('bv::show::modal', 'group-plan-overview'); - } - }, computed: { ...mapState({ user: 'user.data' }), tagsByType () { @@ -175,12 +159,29 @@ export default { }, canCreateTasks () { if (!this.group) return false; - return this.group.leader && this.group.leader._id === this.user._id || this.group.managers && Boolean(this.group.managers[this.user._id]); + return (this.group.leader && this.group.leader._id === this.user._id) + || (this.group.managers && Boolean(this.group.managers[this.user._id])); }, showOptions () { return this.canCreateTasks; }, }, + watch: { + // call again the method if the route changes (when this route is already active) + $route: 'load', + }, + beforeRouteUpdate (to, from, next) { + this.$set(this, 'searchId', to.params.groupId); + next(); + }, + mounted () { + if (!this.searchId) this.searchId = this.groupId; + this.load(); + + if (this.$route.query.showGroupOverview) { + this.$root.$emit('bv::show::modal', 'group-plan-overview'); + } + }, methods: { async load () { this.tasksByType = { @@ -204,7 +205,10 @@ export default { const groupedApprovals = await this.loadApprovals(); tasks.forEach(task => { - if (groupedApprovals[task._id] && groupedApprovals[task._id].length > 0) task.approvals = groupedApprovals[task._id]; + if ( + groupedApprovals[task._id] + && groupedApprovals[task._id].length > 0 + ) task.approvals = groupedApprovals[task._id]; this.tasksByType[task.type].push(task); }); }, diff --git a/website/client/src/components/groups/createPartyModal.vue b/website/client/src/components/groups/createPartyModal.vue index 608d1c08bf..078854c658 100644 --- a/website/client/src/components/groups/createPartyModal.vue +++ b/website/client/src/components/groups/createPartyModal.vue @@ -147,6 +147,7 @@ import notifications from '@/mixins/notifications'; import copyIcon from '@/assets/svg/copy.svg'; export default { + mixins: [notifications], data () { return { icons: Object.freeze({ @@ -189,6 +190,5 @@ export default { this.text(this.$t('usernameCopied')); }, }, - mixins: [notifications], }; diff --git a/website/client/src/components/groups/discovery.vue b/website/client/src/components/groups/discovery.vue index 0d33238b7b..0024626c74 100644 --- a/website/client/src/components/groups/discovery.vue +++ b/website/client/src/components/groups/discovery.vue @@ -67,7 +67,7 @@ function _mapCategories (guilds) { guilds.forEach(guild => { if (!guild.categories) return; guild.categorySlugs = guild.categories.map(cat => { - if (!cat) return; + if (!cat) return undefined; return cat.slug; }); }); @@ -198,7 +198,7 @@ export default { _mapCategories(guilds); this.guilds.push(...guilds); - this.lastPageLoaded++; + this.lastPageLoaded += 1; this.loading = false; }, createGroup () { diff --git a/website/client/src/components/groups/group.vue b/website/client/src/components/groups/group.vue index d9db6f8823..166e2cead0 100644 --- a/website/client/src/components/groups/group.vue +++ b/website/client/src/components/groups/group.vue @@ -448,7 +448,8 @@ export default { const groupId = this.searchId === 'party' ? this.user.party._id : this.searchId; if (this.hasUnreadMessages(groupId)) { - // Delay by 1sec to make sure it returns after other requests that don't have the notification marked as read + // Delay by 1sec to make sure it returns after + // other requests that don't have the notification marked as read setTimeout(() => { this.$store.dispatch('chat:markChatSeen', { groupId }); this.$delete(this.user.newMessages, groupId); @@ -476,7 +477,7 @@ export default { } }, async join () { - if (this.group.cancelledPlan && !confirm(this.$t('aboutToJoinCancelledGroupPlan'))) { + if (this.group.cancelledPlan && !window.confirm(this.$t('aboutToJoinCancelledGroupPlan'))) { return; } await this.$store.dispatch('guilds:join', { groupId: this.group._id, type: 'guild' }); @@ -490,7 +491,7 @@ export default { }); // @TODO: Get challenges and ask to keep or remove - if (!confirm('Are you sure you want to leave?')) return; + if (!window.confirm('Are you sure you want to leave?')) return; const keep = true; this.leave(keep); }, diff --git a/website/client/src/components/groups/groupFormModal.vue b/website/client/src/components/groups/groupFormModal.vue index 41db557c8c..afe7c09e56 100644 --- a/website/client/src/components/groups/groupFormModal.vue +++ b/website/client/src/components/groups/groupFormModal.vue @@ -362,7 +362,7 @@ export default { async submit () { if (this.$store.state.user.data.balance < 1 && !this.workingGroup.id) { // @TODO: Add proper notifications - alert(this.$t('notEnoughGems')); + window.alert(this.$t('notEnoughGems')); return; // @TODO return $rootScope.openModal('buyGems', {track:"Gems > Gems > Create Group"}); } @@ -376,12 +376,12 @@ export default { if (!this.isParty && (!this.workingGroup.categories || this.workingGroup.categories.length === 0)) errors.push(this.$t('categoiresRequired')); if (errors.length > 0) { - alert(errors.join('\n')); + window.alert(errors.join('\n')); return; } // @TODO: Add proper notifications - if (!this.workingGroup.id && !confirm(this.$t('confirmGuild'))) return; + if (!this.workingGroup.id && !window.confirm(this.$t('confirmGuild'))) return; if (!this.workingGroup.privateGuild) { this.workingGroup.privacy = 'public'; diff --git a/website/client/src/components/groups/groupPlan.vue b/website/client/src/components/groups/groupPlan.vue index 95f5978188..0b5998665f 100644 --- a/website/client/src/components/groups/groupPlan.vue +++ b/website/client/src/components/groups/groupPlan.vue @@ -330,9 +330,6 @@ export default { type: 'guild', // Guild or Party @TODO enum this }; }, - mounted () { - this.activePage = this.PAGES.BENEFITS; - }, computed: { newGroupIsReady () { return Boolean(this.newGroup.name); @@ -343,6 +340,9 @@ export default { // @TODO: can we move this to payment mixin? ...mapState({ user: 'user.data' }), }, + mounted () { + this.activePage = this.PAGES.BENEFITS; + }, methods: { launchModal () { this.changePage(this.PAGES.CREATE_GROUP); @@ -370,12 +370,17 @@ export default { } this.paymentMethod = paymentMethod; - if (this.paymentMethod === this.PAYMENTS.STRIPE) { - this.showStripe(paymentData); - } else if (this.paymentMethod === this.PAYMENTS.AMAZON) { + + if (this.paymentMethod === this.PAYMENTS.AMAZON) { paymentData.type = 'subscription'; return paymentData; } + + if (this.paymentMethod === this.PAYMENTS.STRIPE) { + this.showStripe(paymentData); + } + + return null; }, }, }; diff --git a/website/client/src/components/groups/inviteModal.vue b/website/client/src/components/groups/inviteModal.vue index ac9926309e..946787cf19 100644 --- a/website/client/src/components/groups/inviteModal.vue +++ b/website/client/src/components/groups/inviteModal.vue @@ -103,17 +103,8 @@ import positiveIcon from '@/assets/svg/positive.svg'; const INVITE_DEFAULTS = { text: '', error: null, valid: null }; export default { - computed: { - ...mapState({ user: 'user.data' }), - cannotSubmit () { - const filteredInvites = filter(this.invites, invite => invite.text.length > 0 && !invite.valid); - if (filteredInvites.length > 0) return true; - return false; - }, - inviter () { - return this.user.profile.name; - }, - }, + mixins: [notifications], + props: ['group', 'groupType'], data () { return { invites: [clone(INVITE_DEFAULTS), clone(INVITE_DEFAULTS)], @@ -122,36 +113,61 @@ export default { }), }; }, + computed: { + ...mapState({ user: 'user.data' }), + cannotSubmit () { + const filteredInvites = filter( + this.invites, + invite => invite.text.length > 0 && !invite.valid, + ); + if (filteredInvites.length > 0) return true; + return false; + }, + inviter () { + return this.user.profile.name; + }, + }, methods: { checkInviteList: debounce(function checkList () { - this.invites = filter(this.invites, (invite, index) => invite.text.length > 0 || index === this.invites.length - 1); + this.invites = filter( + this.invites, + (invite, index) => invite.text.length > 0 || index === this.invites.length - 1, + ); while (this.invites.length < 2) this.invites.push(clone(INVITE_DEFAULTS)); forEach(this.invites, (value, index) => { if (value.text.length < 1 || isEmail(value.text)) { return this.fillErrors(index); } + if (isUUID(value.text)) { - this.$store.dispatch('user:userLookup', { uuid: value.text }) - .then(res => this.fillErrors(index, res)); - } else { - let searchUsername = value.text; - if (searchUsername[0] === '@') searchUsername = searchUsername.slice(1, searchUsername.length); - this.$store.dispatch('user:userLookup', { username: searchUsername }) + return this.$store.dispatch('user:userLookup', { uuid: value.text }) .then(res => this.fillErrors(index, res)); } + + let searchUsername = value.text; + if (searchUsername[0] === '@') searchUsername = searchUsername.slice(1, searchUsername.length); + return this.$store.dispatch('user:userLookup', { username: searchUsername }) + .then(res => this.fillErrors(index, res)); }); }, 250), expandInviteList () { - if (this.invites[this.invites.length - 1].text.length > 0) this.invites.push(clone(INVITE_DEFAULTS)); + if (this.invites[this.invites.length - 1].text.length > 0) { + this.invites.push(clone(INVITE_DEFAULTS)); + } }, fillErrors (index, res) { if (!res || res.status === 200) { this.invites[index].error = null; - if (this.invites[index].text.length < 1) return this.invites[index].valid = null; - return this.invites[index].valid = true; + if (this.invites[index].text.length < 1) { + this.invites[index].valid = null; + return; + } + + this.invites[index].valid = true; + return; } this.invites[index].error = res.response.data.message; - return this.invites[index].valid = false; + this.invites[index].valid = false; }, close () { this.invites = [clone(INVITE_DEFAULTS), clone(INVITE_DEFAULTS)]; @@ -179,14 +195,13 @@ export default { groupId: this.group._id, }); - const invitesSent = invitationDetails.emails.length + invitationDetails.uuids.length + invitationDetails.usernames.length; + const invitesSent = invitationDetails.emails.length + + invitationDetails.uuids.length + invitationDetails.usernames.length; const invitationString = invitesSent > 1 ? 'invitationsSent' : 'invitationSent'; this.text(this.$t(invitationString)); this.close(); }, }, - mixins: [notifications], - props: ['group', 'groupType'], }; diff --git a/website/client/src/components/groups/membersModal.vue b/website/client/src/components/groups/membersModal.vue index 377395b0a3..09033ea1b5 100644 --- a/website/client/src/components/groups/membersModal.vue +++ b/website/client/src/components/groups/membersModal.vue @@ -277,22 +277,6 @@ export default { userIdToMessage: '', }; }, - mounted () { - this.$root.$on('habitica:show-member-modal', data => { - // @TODO: Remove store - this.$store.state.memberModalOptions.challengeId = data.challengeId; - this.$store.state.memberModalOptions.groupId = data.groupId; - this.$store.state.memberModalOptions.group = data.group; - this.$store.state.memberModalOptions.memberCount = data.memberCount; - this.$store.state.memberModalOptions.viewingMembers = data.viewingMembers; - this.$store.state.memberModalOptions.fetchMoreMembers = data.fetchMoreMembers; - this.$root.$emit('bv::show::modal', 'members-modal'); - this.getMembers(); - }); - }, - destroyed () { - this.$root.$off('habitica:show-member-modal'); - }, computed: { ...mapState({ user: 'user.data' }), isLeader () { @@ -324,7 +308,11 @@ export default { if (!isEmpty(this.sortOption)) { // Use the memberlist filtered by searchTerm - sortedMembers = orderBy(sortedMembers, [this.sortOption.value], [this.sortOption.direction]); + sortedMembers = orderBy( + sortedMembers, + [this.sortOption.value], + [this.sortOption.direction], + ); } return sortedMembers; @@ -351,6 +339,22 @@ export default { } }, }, + mounted () { + this.$root.$on('habitica:show-member-modal', data => { + // @TODO: Remove store + this.$store.state.memberModalOptions.challengeId = data.challengeId; + this.$store.state.memberModalOptions.groupId = data.groupId; + this.$store.state.memberModalOptions.group = data.group; + this.$store.state.memberModalOptions.memberCount = data.memberCount; + this.$store.state.memberModalOptions.viewingMembers = data.viewingMembers; + this.$store.state.memberModalOptions.fetchMoreMembers = data.fetchMoreMembers; + this.$root.$emit('bv::show::modal', 'members-modal'); + this.getMembers(); + }); + }, + destroyed () { + this.$root.$off('habitica:show-member-modal'); + }, methods: { sendMessage (member) { this.$root.$emit('habitica::new-inbox-message', { @@ -423,14 +427,14 @@ export default { groupId: this.groupId, memberId, }); - alert(this.$t('managerAdded')); + window.alert(this.$t('managerAdded')); }, async removeManager (memberId) { await this.$store.dispatch('guilds:removeManager', { groupId: this.groupId, memberId, }); - alert(this.$t('managerRemoved')); + window.alert(this.$t('managerRemoved')); }, close () { this.$root.$emit('bv::hide::modal', 'members-modal'); @@ -488,7 +492,7 @@ export default { groupData.leader = member._id; await this.$store.dispatch('guilds:update', { group: groupData }); - alert(this.$t('leaderChanged')); + window.alert(this.$t('leaderChanged')); groupData.leader = member; this.$root.$emit('updatedGroup', groupData); diff --git a/website/client/src/components/groups/myGuilds.vue b/website/client/src/components/groups/myGuilds.vue index 83c3d6e983..b3e4c157c1 100644 --- a/website/client/src/components/groups/myGuilds.vue +++ b/website/client/src/components/groups/myGuilds.vue @@ -101,9 +101,6 @@ export default { ], }; }, - created () { - this.fetchGuilds(); - }, computed: { ...mapState({ guilds: 'myGuilds', @@ -121,6 +118,9 @@ export default { }); }, }, + created () { + this.fetchGuilds(); + }, methods: { updateSearch (eventData) { this.search = eventData.searchTerm; diff --git a/website/client/src/components/groups/publicGuildItem.vue b/website/client/src/components/groups/publicGuildItem.vue index f6f3a2d53d..e89a99ba95 100644 --- a/website/client/src/components/groups/publicGuildItem.vue +++ b/website/client/src/components/groups/publicGuildItem.vue @@ -152,15 +152,6 @@ export default { }, mixins: [groupUtilities], props: ['guild', 'displayLeave', 'displayGemBank'], - computed: { - ...mapState({ user: 'user.data' }), - isOwner () { - return this.guild.leader && this.guild.leader === this.user._id; - }, - isMember () { - return this.isMemberOfGroup(this.user, this.guild); - }, - }, data () { return { MAX_SUMMARY_SIZE_FOR_GUILDS, @@ -172,6 +163,15 @@ export default { }), }; }, + computed: { + ...mapState({ user: 'user.data' }), + isOwner () { + return this.guild.leader && this.guild.leader === this.user._id; + }, + isMember () { + return this.isMemberOfGroup(this.user, this.guild); + }, + }, methods: { showSuggested (guildId) { const habiticaHelpingGuildId = '5481ccf3-5d2d-48a9-a871-70a7380cee5a'; @@ -181,7 +181,7 @@ export default { }, async join () { // @TODO: This needs to be in the notifications where users will now accept invites - if (this.guild.cancelledPlan && !confirm(window.env.t('aboutToJoinCancelledGroupPlan'))) { + if (this.guild.cancelledPlan && !window.confirm(window.env.t('aboutToJoinCancelledGroupPlan'))) { return; } await this.$store.dispatch('guilds:join', { groupId: this.guild._id, type: 'guild' }); diff --git a/website/client/src/components/groups/questDetailsModal.vue b/website/client/src/components/groups/questDetailsModal.vue index e442548f1e..41c3a5f7be 100644 --- a/website/client/src/components/groups/questDetailsModal.vue +++ b/website/client/src/components/groups/questDetailsModal.vue @@ -200,7 +200,10 @@ export default { for (const uuid in this.group.quest.members) { if (this.group.quest.members[uuid]) count += 1; } - if (!confirm(this.$t('questConfirm', { questmembers: count, totalmembers: this.group.memberCount }))) return; + if (!window.confirm(this.$t('questConfirm', { + questmembers: count, + totalmembers: this.group.memberCount, + }))) return; this.questForceStart(); }, async questForceStart () { @@ -209,7 +212,7 @@ export default { this.close(); }, async questCancel () { - if (!confirm(this.$t('sureCancel'))) return; + if (!window.confirm(this.$t('sureCancel'))) return; const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/cancel' }); this.group.quest = quest; this.close(); diff --git a/website/client/src/components/groups/questSidebarSection.vue b/website/client/src/components/groups/questSidebarSection.vue index fe6868cebf..7eb2e897ee 100644 --- a/website/client/src/components/groups/questSidebarSection.vue +++ b/website/client/src/components/groups/questSidebarSection.vue @@ -271,13 +271,13 @@ export default { this.$root.$emit('bv::show::modal', 'participant-list'); }, async questAbort () { - if (!confirm(this.$t('sureAbort'))) return; - if (!confirm(this.$t('doubleSureAbort'))) return; + if (!window.confirm(this.$t('sureAbort'))) return; + if (!window.confirm(this.$t('doubleSureAbort'))) return; const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/abort' }); this.group.quest = quest; }, async questLeave () { - if (!confirm(this.$t('sureLeave'))) return; + if (!window.confirm(this.$t('sureLeave'))) return; const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/leave' }); this.group.quest = quest; }, diff --git a/website/client/src/components/groups/startQuestModal.vue b/website/client/src/components/groups/startQuestModal.vue index c310dd4e86..1f1ffccc39 100644 --- a/website/client/src/components/groups/startQuestModal.vue +++ b/website/client/src/components/groups/startQuestModal.vue @@ -147,6 +147,12 @@ export default { quests, }; }, + computed: { + ...mapState({ user: 'user.data' }), + questData () { + return quests.quests[this.selectedQuest]; + }, + }, mounted () { const userQuests = this.user.items.quests; for (const key in userQuests) { @@ -161,12 +167,6 @@ export default { destroyed () { this.$root.$off('selectQuest', this.selectQuest); }, - computed: { - ...mapState({ user: 'user.data' }), - questData () { - return quests.quests[this.selectedQuest]; - }, - }, methods: { selectQuest (quest) { this.selectedQuest = quest.key; diff --git a/website/client/src/components/hall/heroes.vue b/website/client/src/components/hall/heroes.vue index 6b24194483..06b50ef035 100644 --- a/website/client/src/components/hall/heroes.vue +++ b/website/client/src/components/hall/heroes.vue @@ -144,28 +144,43 @@ export default { expandAuth: false, }; }, - async mounted () { - this.heroes = await this.$store.dispatch('hall:getHeroes'); - }, computed: { ...mapState({ user: 'user.data' }), }, + async mounted () { + this.heroes = await this.$store.dispatch('hall:getHeroes'); + }, methods: { getAllItemPaths () { - // let questsFormat = this.getFormattedItemReference('items.quests', keys(this.quests), 'Numeric Quantity'); - // let mountsFormat = this.getFormattedItemReference('items.mounts', keys(this.mountInfo), 'Boolean'); - // let foodFormat = this.getFormattedItemReference('items.food', keys(this.food), 'Numeric Quantity'); - // let eggsFormat = this.getFormattedItemReference('items.eggs', keys(this.eggs), 'Numeric Quantity'); - // let hatchingPotionsFormat = this.getFormattedItemReference('items.hatchingPotions', keys(this.hatchingPotions), 'Numeric Quantity'); - // let petsFormat = this.getFormattedItemReference('items.pets', keys(this.petInfo), '-1: Owns Mount, 0: Not Owned, 1-49: Progress to mount'); - // let specialFormat = this.getFormattedItemReference('items.special', keys(this.special), 'Numeric Quantity'); - // let gearFormat = this.getFormattedItemReference('items.gear.owned', keys(this.gear.flat), 'Boolean'); + // let questsFormat = this.getFormattedItemReference + // ('items.quests', keys(this.quests), 'Numeric Quantity'); + // let mountsFormat = this.getFormattedItemReference + // ('items.mounts', keys(this.mountInfo), 'Boolean'); + // let foodFormat = this.getFormattedItemReference + // ('items.food', keys(this.food), 'Numeric Quantity'); + // let eggsFormat = this.getFormattedItemReference + // ('items.eggs', keys(this.eggs), 'Numeric Quantity'); + // let hatchingPotionsFormat = this.getFormattedItemReference + // ('items.hatchingPotions', keys(this.hatchingPotions), 'Numeric Quantity'); + // let petsFormat = this.getFormattedItemReference + // ('items.pets', keys(this.petInfo), '-1: + // Owns Mount, 0: Not Owned, 1-49: Progress to mount'); + // let specialFormat = this.getFormattedItemReference + // ('items.special', keys(this.special), 'Numeric Quantity'); + // let gearFormat = this.getFormattedItemReference + // ('items.gear.owned', keys(this.gear.flat), 'Boolean'); // - // let equippedGearFormat = ''; // @TODO: '\nEquipped Gear:\n\titems.gear.{equipped/costume}.{head/headAccessory/eyewear/armor/body/back/shield/weapon}.{gearKey}\n'; - // let equippedPetFormat = ''; // @TODO: '\nEquipped Pet:\n\titems.currentPet.{petKey}\n'; - // let equippedMountFormat = ''; // @TODO: '\nEquipped Mount:\n\titems.currentMount.{mountKey}\n'; + // let equippedGearFormat = ''; // @TODO: + // '\nEquipped Gear:\n\titems.gear.{equipped/costume} + // .{head/headAccessory/eyewear/armor/body/back/shield/weapon}.{gearKey}\n'; + // let equippedPetFormat = ''; // @TODO:'\nEquipped Pet:\n\titems.currentPet.{petKey}\n'; + // let equippedMountFormat = ''; // @TODO: + // '\nEquipped Mount:\n\titems.currentMount.{mountKey}\n'; // - // let data = questsFormat.concat(mountsFormat, foodFormat, eggsFormat, hatchingPotionsFormat, petsFormat, specialFormat, gearFormat, equippedGearFormat, equippedPetFormat, equippedMountFormat); + // let data = questsFormat.concat(mountsFormat, + // foodFormat, eggsFormat, hatchingPotionsFormat, + // petsFormat, specialFormat, gearFormat, equippedGearFormat, + // equippedPetFormat, equippedMountFormat); // // return data; }, diff --git a/website/client/src/components/hall/patrons.vue b/website/client/src/components/hall/patrons.vue index ec090b9077..85234bbf01 100644 --- a/website/client/src/components/hall/patrons.vue +++ b/website/client/src/components/hall/patrons.vue @@ -28,12 +28,12 @@ export default { patrons: [], }; }, - async mounted () { - this.patrons = await this.$store.dispatch('hall:getPatrons', { page: 0 }); - }, computed: { ...mapState({ user: 'user.data' }), }, + async mounted () { + this.patrons = await this.$store.dispatch('hall:getPatrons', { page: 0 }); + }, methods: { // @TODO: Import member modal - clickMember() }, diff --git a/website/client/src/components/header/index.vue b/website/client/src/components/header/index.vue index 3104b679ff..11b2962749 100644 --- a/website/client/src/components/header/index.vue +++ b/website/client/src/components/header/index.vue @@ -129,7 +129,8 @@ export default { return true; }, hasParty () { - return this.user.party && this.user.party._id && this.partyMembers && this.partyMembers.length > 1; + return this.user.party && this.user.party._id + && this.partyMembers && this.partyMembers.length > 1; }, membersToShow () { return Math.floor(this.currentWidth / 140) + 1; @@ -138,6 +139,22 @@ export default { return orderBy(this.partyMembers, [this.user.party.order], [this.user.party.orderAscending]); }, }, + created () { + if (this.user.party && this.user.party._id) { + this.$store.state.memberModalOptions.groupId = this.user.party._id; + this.getPartyMembers(); + } + }, + mounted () { + this.$root.$on('inviteModal::inviteToGroup', group => { + this.inviteModalGroup = group; + this.inviteModalGroupType = group.type === 'guild' ? 'Guild' : 'Party'; + this.$root.$emit('bv::show::modal', 'invite-modal'); + }); + }, + destroyed () { + this.$root.off('inviteModal::inviteToGroup'); + }, methods: { ...mapActions({ getPartyMembers: 'party:getMembers', @@ -171,21 +188,5 @@ export default { } }, }, - created () { - if (this.user.party && this.user.party._id) { - this.$store.state.memberModalOptions.groupId = this.user.party._id; - this.getPartyMembers(); - } - }, - mounted () { - this.$root.$on('inviteModal::inviteToGroup', group => { - this.inviteModalGroup = group; - this.inviteModalGroupType = group.type === 'guild' ? 'Guild' : 'Party'; - this.$root.$emit('bv::show::modal', 'invite-modal'); - }); - }, - destroyed () { - this.$root.off('inviteModal::inviteToGroup'); - }, }; diff --git a/website/client/src/components/header/notificationsDropdown.vue b/website/client/src/components/header/notificationsDropdown.vue index 74d410fe78..c62d8c2d0b 100644 --- a/website/client/src/components/header/notificationsDropdown.vue +++ b/website/client/src/components/header/notificationsDropdown.vue @@ -220,7 +220,8 @@ export default { })); // Sort notifications - notifications.sort((a, b) => { // a and b are notifications + // a and b are notifications + notifications.sort((a, b) => { // eslint-disable-line array-callback-return, consistent-return const aOrder = orderMap[a.type]; const bOrder = orderMap[b.type]; @@ -261,6 +262,7 @@ export default { if (notification.seen === false && notification.id && notification.id.indexOf('custom-') !== 0) { return notification.id; } + return null; }).filter(id => Boolean(id)); if (idsToSee.length > 0) this.seeNotifications({ notificationIds: idsToSee }); @@ -273,6 +275,7 @@ export default { if (!this.isActionable(notification) && notification.id.indexOf('custom-') !== 0) { return notification.id; } + return null; }).filter(id => Boolean(id)); this.openStatus = 0; diff --git a/website/client/src/components/inventory/equipment/equipGearModal.vue b/website/client/src/components/inventory/equipment/equipGearModal.vue index d3c679399a..bab453405c 100644 --- a/website/client/src/components/inventory/equipment/equipGearModal.vue +++ b/website/client/src/components/inventory/equipment/equipGearModal.vue @@ -133,6 +133,20 @@ export default { Avatar, attributesGrid, }, + props: { + item: { + type: Object, + }, + priceType: { + type: String, + }, + costumeMode: { + type: Boolean, + }, + isEquipped: { + type: Boolean, + }, + }, data () { return { icons: Object.freeze({ @@ -198,19 +212,5 @@ export default { return this.$t(classType); }, }, - props: { - item: { - type: Object, - }, - priceType: { - type: String, - }, - costumeMode: { - type: Boolean, - }, - isEquipped: { - type: Boolean, - }, - }, }; diff --git a/website/client/src/components/inventory/equipment/index.vue b/website/client/src/components/inventory/equipment/index.vue index 8a132d48b0..d1d2afcc6c 100644 --- a/website/client/src/components/inventory/equipment/index.vue +++ b/website/client/src/components/inventory/equipment/index.vue @@ -212,6 +212,130 @@ export default { selectedSortGearBy: 'sortByName', }; }, + computed: { + ...mapState({ + content: 'content', + user: 'user.data', + ownedItems: 'user.data.items.gear.owned', + equippedItems: 'user.data.items.gear.equipped', + costumeItems: 'user.data.items.gear.costume', + flatGear: 'content.gear.flat', + }), + openStatus () { + return this.$store.state.equipmentDrawerOpen ? 1 : 0; + }, + drawerPreference () { + return this.costumeMode ? 'costume' : 'autoEquip'; + }, + activeItems () { + return this.costumeMode ? this.costumeItems : this.equippedItems; + }, + gearItemsByType () { + const searchText = this.searchTextThrottled; + const gearItemsByType = {}; + each(this.gearTypesToStrings, (string, type) => { + gearItemsByType[type] = []; + }); + + each(this.ownedItems, (isOwned, gearKey) => { + if (isOwned === true) { + const ownedItem = this.flatGear[gearKey]; + + const isSearched = !searchText + || ownedItem.text().toLowerCase().indexOf(searchText) !== -1; + + if (ownedItem.klass !== 'base' && isSearched) { + const { type } = ownedItem; + const isEquipped = this.activeItems[type] === ownedItem.key; + const viewOptions = this.viewOptions[type]; + const { firstRender } = viewOptions; + const { itemsInFirstPosition } = viewOptions; + + // Render selected items in first postion only for the first render + if (itemsInFirstPosition.indexOf(ownedItem.key) !== -1 && firstRender === false) { + gearItemsByType[type].unshift(ownedItem); + } else if (isEquipped === true && firstRender === true) { + gearItemsByType[type].unshift(ownedItem); + itemsInFirstPosition.push(ownedItem.key); + } else { + gearItemsByType[type].push(ownedItem); + } + } + } + }); + + + each(this.gearTypesToStrings, (string, type) => { + this.viewOptions[type].firstRender = false; // eslint-disable-line vue/no-side-effects-in-computed-properties, max-len + }); + + return gearItemsByType; + }, + gearItemsByClass () { + const searchText = this.searchTextThrottled; + const gearItemsByClass = {}; + each(this.gearClassesToStrings, (string, klass) => { + gearItemsByClass[klass] = []; + }); + + each(this.ownedItems, (isOwned, gearKey) => { + if (isOwned === true) { + const ownedItem = this.flatGear[gearKey]; + const { klass } = ownedItem; + + const isSearched = !searchText + || ownedItem.text().toLowerCase().indexOf(searchText) !== -1; + + if (klass !== 'base' && isSearched) { + const isEquipped = this.activeItems[ownedItem.type] === ownedItem.key; + const viewOptions = this.viewOptions[klass]; + const { firstRender } = viewOptions; + const { itemsInFirstPosition } = viewOptions; + + // Render selected items in first postion only for the first render + if (itemsInFirstPosition.indexOf(ownedItem.key) !== -1 && firstRender === false) { + gearItemsByClass[klass].unshift(ownedItem); + } else if (isEquipped === true && firstRender === true) { + gearItemsByClass[klass].unshift(ownedItem); + itemsInFirstPosition.push(ownedItem.key); + } else { + gearItemsByClass[klass].push(ownedItem); + } + } + } + }); + + each(this.gearClassesToStrings, (string, klass) => { + this.viewOptions[klass].firstRender = false; // eslint-disable-line vue/no-side-effects-in-computed-properties, max-len + }); + + return gearItemsByClass; + }, + groups () { + return this.groupBy === 'type' ? this.gearTypesToStrings : this.gearClassesToStrings; + }, + items () { + return this.groupBy === 'type' ? this.gearItemsByType : this.gearItemsByClass; + }, + anyFilterSelected () { + return Object.values(this.viewOptions).some(g => g.selected); + }, + itemsGroups () { + return map(this.groups, (label, group) => { + this.$set(this.viewOptions, group, { + selected: false, + open: false, + itemsInFirstPosition: [], + firstRender: true, + }); + + return { + key: group, + label, + }; + }); + }, + }, watch: { searchText: throttle(function throttleSearch () { this.searchTextThrottled = this.searchText.toLowerCase(); @@ -223,7 +347,9 @@ export default { this.$store.state.equipmentDrawerOpen = false; } - this.costumeMode = getLocalSetting(CONSTANTS.keyConstants.CURRENT_EQUIPMENT_DRAWER_TAB) === CONSTANTS.equipmentDrawerTabValues.COSTUME_TAB; + this.costumeMode = getLocalSetting( + CONSTANTS.keyConstants.CURRENT_EQUIPMENT_DRAWER_TAB, + ) === CONSTANTS.equipmentDrawerTabValues.COSTUME_TAB; }, methods: { selectDrawerTab (tabName) { @@ -273,133 +399,17 @@ export default { this.$store.state.equipmentDrawerOpen = newState; if (newState) { - setLocalSetting(CONSTANTS.keyConstants.EQUIPMENT_DRAWER_STATE, CONSTANTS.drawerStateValues.DRAWER_OPEN); + setLocalSetting( + CONSTANTS.keyConstants.EQUIPMENT_DRAWER_STATE, + CONSTANTS.drawerStateValues.DRAWER_OPEN, + ); return; } - setLocalSetting(CONSTANTS.keyConstants.EQUIPMENT_DRAWER_STATE, CONSTANTS.drawerStateValues.DRAWER_CLOSED); - }, - }, - computed: { - ...mapState({ - content: 'content', - user: 'user.data', - ownedItems: 'user.data.items.gear.owned', - equippedItems: 'user.data.items.gear.equipped', - costumeItems: 'user.data.items.gear.costume', - flatGear: 'content.gear.flat', - }), - openStatus () { - return this.$store.state.equipmentDrawerOpen ? 1 : 0; - }, - drawerPreference () { - return this.costumeMode ? 'costume' : 'autoEquip'; - }, - activeItems () { - return this.costumeMode ? this.costumeItems : this.equippedItems; - }, - gearItemsByType () { - const searchText = this.searchTextThrottled; - const gearItemsByType = {}; - each(this.gearTypesToStrings, (string, type) => { - gearItemsByType[type] = []; - }); - - each(this.ownedItems, (isOwned, gearKey) => { - if (isOwned === true) { - const ownedItem = this.flatGear[gearKey]; - - const isSearched = !searchText || ownedItem.text().toLowerCase().indexOf(searchText) !== -1; - - if (ownedItem.klass !== 'base' && isSearched) { - const { type } = ownedItem; - const isEquipped = this.activeItems[type] === ownedItem.key; - const viewOptions = this.viewOptions[type]; - const { firstRender } = viewOptions; - const { itemsInFirstPosition } = viewOptions; - - // Render selected items in first postion only for the first render - if (itemsInFirstPosition.indexOf(ownedItem.key) !== -1 && firstRender === false) { - gearItemsByType[type].unshift(ownedItem); - } else if (isEquipped === true && firstRender === true) { - gearItemsByType[type].unshift(ownedItem); - itemsInFirstPosition.push(ownedItem.key); - } else { - gearItemsByType[type].push(ownedItem); - } - } - } - }); - - - each(this.gearTypesToStrings, (string, type) => { - this.viewOptions[type].firstRender = false; // eslint-disable-line vue/no-side-effects-in-computed-properties - }); - - return gearItemsByType; - }, - gearItemsByClass () { - const searchText = this.searchTextThrottled; - const gearItemsByClass = {}; - each(this.gearClassesToStrings, (string, klass) => { - gearItemsByClass[klass] = []; - }); - - each(this.ownedItems, (isOwned, gearKey) => { - if (isOwned === true) { - const ownedItem = this.flatGear[gearKey]; - const { klass } = ownedItem; - - const isSearched = !searchText || ownedItem.text().toLowerCase().indexOf(searchText) !== -1; - - if (klass !== 'base' && isSearched) { - const isEquipped = this.activeItems[ownedItem.type] === ownedItem.key; - const viewOptions = this.viewOptions[klass]; - const { firstRender } = viewOptions; - const { itemsInFirstPosition } = viewOptions; - - // Render selected items in first postion only for the first render - if (itemsInFirstPosition.indexOf(ownedItem.key) !== -1 && firstRender === false) { - gearItemsByClass[klass].unshift(ownedItem); - } else if (isEquipped === true && firstRender === true) { - gearItemsByClass[klass].unshift(ownedItem); - itemsInFirstPosition.push(ownedItem.key); - } else { - gearItemsByClass[klass].push(ownedItem); - } - } - } - }); - - each(this.gearClassesToStrings, (string, klass) => { - this.viewOptions[klass].firstRender = false; // eslint-disable-line vue/no-side-effects-in-computed-properties - }); - - return gearItemsByClass; - }, - groups () { - return this.groupBy === 'type' ? this.gearTypesToStrings : this.gearClassesToStrings; - }, - items () { - return this.groupBy === 'type' ? this.gearItemsByType : this.gearItemsByClass; - }, - anyFilterSelected () { - return Object.values(this.viewOptions).some(g => g.selected); - }, - itemsGroups () { - return map(this.groups, (label, group) => { - this.$set(this.viewOptions, group, { - selected: false, - open: false, - itemsInFirstPosition: [], - firstRender: true, - }); - - return { - key: group, - label, - }; - }); + setLocalSetting( + CONSTANTS.keyConstants.EQUIPMENT_DRAWER_STATE, + CONSTANTS.drawerStateValues.DRAWER_CLOSED, + ); }, }, }; diff --git a/website/client/src/components/inventory/items/cards-modal.vue b/website/client/src/components/inventory/items/cards-modal.vue index ec5ad2d32f..562f171156 100644 --- a/website/client/src/components/inventory/items/cards-modal.vue +++ b/website/client/src/components/inventory/items/cards-modal.vue @@ -37,7 +37,10 @@ export default { }, numberOfVariations () { let numberOfVariations = 0; - if (this.cardOptions && this.cardOptions.messageOptions) numberOfVariations = this.cardOptions.messageOptions; + if ( + this.cardOptions + && this.cardOptions.messageOptions + ) numberOfVariations = this.cardOptions.messageOptions; return numberOfVariations; }, cardMessage () { @@ -48,7 +51,7 @@ export default { fromName () { let fromName = ''; const card = this.user.items.special[`${this.cardType}Received`]; - if (card && card[0]) fromName = card[0]; + if (card && card[0]) [fromName] = card; return fromName; }, }, diff --git a/website/client/src/components/inventory/items/index.vue b/website/client/src/components/inventory/items/index.vue index 4a8ef581f8..4987cddad3 100644 --- a/website/client/src/components/inventory/items/index.vue +++ b/website/client/src/components/inventory/items/index.vue @@ -264,11 +264,6 @@ export default { }, }; }, - watch: { - searchText: throttle(function throttleSearch () { - this.searchTextThrottled = this.searchText.toLowerCase(); - }, 250), - }, computed: { ...mapState({ content: 'content', @@ -281,7 +276,8 @@ export default { this.groups.forEach(group => { const groupKey = group.key; group.quantity = 0; // resetf the count - const itemsArray = itemsByType[groupKey] = []; + itemsByType[groupKey] = []; + const itemsArray = itemsByType[groupKey]; const contentItems = this.content[groupKey]; each(this.user.items[groupKey], (itemQuantity, itemKey) => { @@ -342,6 +338,11 @@ export default { return this.groups.some(g => g.selected); }, }, + watch: { + searchText: throttle(function throttleSearch () { + this.searchTextThrottled = this.searchText.toLowerCase(); + }, 250), + }, methods: { userHasPet (potionKey, eggKey) { const animalKey = `${eggKey}-${potionKey}`; diff --git a/website/client/src/components/inventory/stable/index.vue b/website/client/src/components/inventory/stable/index.vue index 1fea83fc89..c0aeedbc0a 100644 --- a/website/client/src/components/inventory/stable/index.vue +++ b/website/client/src/components/inventory/stable/index.vue @@ -411,17 +411,6 @@ export default { selectedDrawerTab: 0, }; }, - watch: { - searchText: _throttle(function throttleSearch () { - const search = this.searchText.toLowerCase(); - this.searchTextThrottled = search; - }, 250), - selectedSortBy: { - handler () { - setLocalSetting(CONSTANTS.keyConstants.STABLE_SORT_STATE, this.selectedSortBy); - }, - }, - }, computed: { ...mapState({ content: 'content', @@ -473,7 +462,7 @@ export default { }, ]; - petGroups.map(petGroup => { + petGroups.forEach(petGroup => { this.$set(this.viewOptions, petGroup.key, { selected: false, animalCount: 0, @@ -518,7 +507,7 @@ export default { }, ]; - mountGroups.map(mountGroup => { + mountGroups.forEach(mountGroup => { this.$set(this.viewOptions, mountGroup.key, { selected: false, animalCount: 0, @@ -544,6 +533,17 @@ export default { return Object.values(this.viewOptions).some(g => g.selected); }, }, + watch: { + searchText: _throttle(function throttleSearch () { + const search = this.searchText.toLowerCase(); + this.searchTextThrottled = search; + }, 250), + selectedSortBy: { + handler () { + setLocalSetting(CONSTANTS.keyConstants.STABLE_SORT_STATE, this.selectedSortBy); + }, + }, + }, methods: { setShowMore (key) { this.$_openedItemRows_toggleByType(key, !this.$_openedItemRows_isToggled(key)); @@ -615,7 +615,7 @@ export default { } // 2. Sort - switch (sort) { + switch (sort) { // eslint-disable-line default-case case 'AZ': animals = _sortBy(animals, ['eggName']); break; @@ -642,9 +642,8 @@ export default { const animals = this.getAnimalList(animalGroup, type); const countAll = animals.length; - const countOwned = _filter(animals, a => // when counting pets, include those that have been raised into mounts - a.isOwned() || a.mountOwned()); + const countOwned = _filter(animals, a => a.isOwned() || a.mountOwned()); return `${countOwned.length}/${countAll}`; }, diff --git a/website/client/src/components/inventory/stable/mountRaisedModal.vue b/website/client/src/components/inventory/stable/mountRaisedModal.vue index daa873e373..e69163c3a7 100644 --- a/website/client/src/components/inventory/stable/mountRaisedModal.vue +++ b/website/client/src/components/inventory/stable/mountRaisedModal.vue @@ -73,9 +73,6 @@ export default { return { mount: null, }; - }, - created () { - }, mounted () { this.$root.$on('habitica::mount-raised', this.openDialog); diff --git a/website/client/src/components/inventory/stable/petItem.vue b/website/client/src/components/inventory/stable/petItem.vue index 55fabceae5..1ddac32ffd 100644 --- a/website/client/src/components/inventory/stable/petItem.vue +++ b/website/client/src/components/inventory/stable/petItem.vue @@ -103,6 +103,17 @@ export default { itemId: uuid.v4(), }); }, + computed: { + ...mapState({ + userItems: 'user.data.items', + }), + potionClass () { + return `Pet_HatchingPotion_${this.item.potionKey}`; + }, + eggClass () { + return `Pet_Egg_${this.item.eggKey}`; + }, + }, methods: { click () { this.$emit('click', {}); @@ -114,7 +125,7 @@ export default { return isAllowedToFeed(this.item, this.userItems); }, getPetItemClass () { - if (this.isOwned() || this.mountOwned() && this.isHatchable()) { + if (this.isOwned() || (this.mountOwned() && this.isHatchable())) { return `Pet Pet-${this.item.key} ${this.item.eggKey}`; } @@ -148,16 +159,5 @@ export default { return isSpecial(this.item); }, }, - computed: { - ...mapState({ - userItems: 'user.data.items', - }), - potionClass () { - return `Pet_HatchingPotion_${this.item.potionKey}`; - }, - eggClass () { - return `Pet_Egg_${this.item.eggKey}`; - }, - }, }; diff --git a/website/client/src/components/memberDetails.vue b/website/client/src/components/memberDetails.vue index 44392e2757..5c72c374b6 100644 --- a/website/client/src/components/memberDetails.vue +++ b/website/client/src/components/memberDetails.vue @@ -201,12 +201,6 @@ export default { }), }; }, - methods: { - percent, - showMemberModal (member) { - this.$router.push({ name: 'userProfile', params: { userId: member._id } }); - }, - }, computed: { ...mapState({ MAX_HEALTH: 'constants.MAX_HEALTH', @@ -229,5 +223,11 @@ export default { return this.$store.getters['members:hasClass'](this.member); }, }, + methods: { + percent, + showMemberModal (member) { + this.$router.push({ name: 'userProfile', params: { userId: member._id } }); + }, + }, }; diff --git a/website/client/src/components/members/groupMemberSearchDropdown.vue b/website/client/src/components/members/groupMemberSearchDropdown.vue index 7a383e6de2..f62c8a346d 100644 --- a/website/client/src/components/members/groupMemberSearchDropdown.vue +++ b/website/client/src/components/members/groupMemberSearchDropdown.vue @@ -35,14 +35,14 @@ export default { memberResults: [], }; }, - mounted () { - this.memberResults = this.members; - }, watch: { searchTerm: debounce(function searchTerm (newSearch) { this.searchMember(newSearch); }, 500), }, + mounted () { + this.memberResults = this.members; + }, methods: { selectMember (member) { this.$emit('member-selected', member); diff --git a/website/client/src/components/modifyInventory.vue b/website/client/src/components/modifyInventory.vue index 866a75cb36..142ee47fda 100644 --- a/website/client/src/components/modifyInventory.vue +++ b/website/client/src/components/modifyInventory.vue @@ -261,9 +261,6 @@ import { mapState } from '@/libs/store'; import Content from '@/../../common/script/content'; export default { - computed: { - ...mapState({ user: 'user.data' }), - }, data () { const showInv = {}; const inv = { @@ -283,14 +280,15 @@ export default { content: Content, }; }, + computed: { + ...mapState({ user: 'user.data' }), + }, methods: { setAllItems (type, value) { const set = this.inv[type]; - for (const item in set) { - if (set.hasOwnProperty(item)) { - set[item] = value; - } + for (const item of Object.keys(set)) { + set[item] = value; } }, async modifyInventory () { diff --git a/website/client/src/components/notifications.vue b/website/client/src/components/notifications.vue index 1f55641fd6..a5f7e9d278 100644 --- a/website/client/src/components/notifications.vue +++ b/website/client/src/components/notifications.vue @@ -433,11 +433,14 @@ export default { } }, checkUserAchievements () { - if (this.user.needsCron) return; + if (this.user.needsCron) return null; - // List of prompts for user on changes. Sounds like we may need a refactor here, but it is clean for now + // List of prompts for user on changes. + // Sounds like we may need a refactor here, but it is clean for now if (!this.user.flags.welcomed) { - if (this.$store.state.avatarEditorOptions) this.$store.state.avatarEditorOptions.editingUser = false; + if (this.$store.state.avatarEditorOptions) { + this.$store.state.avatarEditorOptions.editingUser = false; + } return this.$root.$emit('bv::show::modal', 'avatar-modal'); } @@ -458,6 +461,8 @@ export default { this.playSound('Achievement_Unlocked'); return this.$root.$emit('bv::show::modal', 'choose-class'); } + + return null; }, showLevelUpNotifications (newlevel) { this.lvl(); @@ -470,7 +475,11 @@ export default { this.$root.$emit('playSound', sound); }, checkNextCron: throttle(function checkNextCron () { - if (!this.$store.state.isRunningYesterdailies && this.nextCron && Date.now() > this.nextCron) { + if ( + !this.$store.state.isRunningYesterdailies + && this.nextCron + && Date.now() > this.nextCron + ) { Promise.all([ this.$store.dispatch('user:fetch', { forceLoad: true }), this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true }), @@ -540,7 +549,10 @@ export default { this.$store.state.isRunningYesterdailies = false; - if (this.levelBeforeYesterdailies > 0 && this.levelBeforeYesterdailies < this.user.stats.lvl) { + if ( + this.levelBeforeYesterdailies > 0 + && this.levelBeforeYesterdailies < this.user.stats.lvl + ) { this.showLevelUpNotifications(this.user.stats.lvl); } @@ -571,7 +583,7 @@ export default { let markAsRead = true; // @TODO: Use factory function instead - switch (notification.type) { + switch (notification.type) { // eslint-disable-line default-case case 'GUILD_PROMPT': // @TODO: I'm pretty sure we can find better names for these if (notification.data.textletiant === -1) { @@ -619,7 +631,7 @@ export default { break; case 'SCORED_TASK': // Search if it is a read notification - for (let i = 0; i < this.alreadyReadNotification.length; i++) { + for (let i = 0; i < this.alreadyReadNotification.length; i += 1) { if (this.alreadyReadNotification[i] === notification.id) { markAsRead = false; // Do not let it be read again break; @@ -659,7 +671,7 @@ export default { // Only run this code for scoring approved tasks if (scoreTaskNotification.length > 0) { const approvedTasks = []; - for (let i = 0; i < scoreTaskNotification.length; i++) { + for (let i = 0; i < scoreTaskNotification.length; i += 1) { // Array with all approved tasks const scoreData = scoreTaskNotification[i].data; let direction = 'up'; diff --git a/website/client/src/components/payments/amazonButton.vue b/website/client/src/components/payments/amazonButton.vue index 9924df7691..1e37215017 100644 --- a/website/client/src/components/payments/amazonButton.vue +++ b/website/client/src/components/payments/amazonButton.vue @@ -62,13 +62,14 @@ export default { this.amazonPaymentsInit(this.amazonData); if (this.isAmazonReady) return this.setupAmazon(); - this.$store.watch(state => state.isAmazonReady, isAmazonReady => { + return this.$store.watch(state => state.isAmazonReady, isAmazonReady => { if (isAmazonReady) return this.setupAmazon(); + return null; }); }, methods: { setupAmazon () { - if (this.isAmazonSetup) return false; + if (this.isAmazonSetup) return; this.isAmazonSetup = true; this.showButton(); }, @@ -91,16 +92,17 @@ export default { this.$root.$emit('habitica::pay-with-amazon', this.amazonPayments); }, authorization: () => { - if (this.amazonDisabled === true) return null; + if (this.amazonDisabled === true) return; + window.amazon.Login.authorize({ scope: 'payments:widget', popup: true, }, response => { - if (response.error) return alert(response.error); + if (response.error) return window.alert(response.error); const url = '/amazon/verifyAccessToken'; - axios.post(url, response).catch(e => { - alert(e.message); + return axios.post(url, response).catch(e => { + window.alert(e.message); }); }); }, diff --git a/website/client/src/components/payments/amazonModal.vue b/website/client/src/components/payments/amazonModal.vue index 90c605a4ae..8ae4903c11 100644 --- a/website/client/src/components/payments/amazonModal.vue +++ b/website/client/src/components/payments/amazonModal.vue @@ -35,7 +35,7 @@ import * as Analytics from '@/libs/analytics'; import { mapState } from '@/libs/store'; import { CONSTANTS, setLocalSetting } from '@/libs/userlocalManager'; -const habiticaUrl = `${location.protocol}//${location.host}`; +const habiticaUrl = `${window.location.protocol}//${window.location.host}`; export default { data () { @@ -95,7 +95,7 @@ export default { this.amazonPayments.orderReferenceId = response.data.data.orderReferenceId; this.amazonInitWidgets(); } else { - alert(response.message); + window.alert(response.message); } } }); diff --git a/website/client/src/components/payments/buyGemsModal.vue b/website/client/src/components/payments/buyGemsModal.vue index 04f0d0a66c..6767e50cfe 100644 --- a/website/client/src/components/payments/buyGemsModal.vue +++ b/website/client/src/components/payments/buyGemsModal.vue @@ -329,22 +329,10 @@ export default { planGemLimits, amazonButton, }, - mixins: [paymentsMixin], - computed: { - ...mapState({ user: 'user.data' }), - startingPageOption () { - return this.$store.state.gemModalOptions.startingPage; - }, - hasSubscription () { - return Boolean(this.user.purchased.plan.customerId); - }, - userReachedGemCap () { - return this.user.purchased.plan.customerId && this.user.purchased.plan.gemsBought >= this.user.purchased.plan.consecutive.gemCapExtra + this.planGemLimits.convCap; - }, - }, directives: { markdown, }, + mixins: [paymentsMixin], data () { return { icons: Object.freeze({ @@ -363,6 +351,19 @@ export default { planGemLimits, }; }, + computed: { + ...mapState({ user: 'user.data' }), + startingPageOption () { + return this.$store.state.gemModalOptions.startingPage; + }, + hasSubscription () { + return Boolean(this.user.purchased.plan.customerId); + }, + userReachedGemCap () { + return this.user.purchased.plan.customerId + && this.user.purchased.plan.gemsBought >= this.user.purchased.plan.consecutive.gemCapExtra + this.planGemLimits.convCap; + }, + }, watch: { startingPageOption () { this.selectedPage = this.$store.state.gemModalOptions.startingPage; diff --git a/website/client/src/components/payments/sendGemsModal.vue b/website/client/src/components/payments/sendGemsModal.vue index 0174162ba9..71cb106c4f 100644 --- a/website/client/src/components/payments/sendGemsModal.vue +++ b/website/client/src/components/payments/sendGemsModal.vue @@ -153,7 +153,11 @@ export default { return this.$t('sendGiftHeading', { name: this.userReceivingGems.profile.name }); }, receiverName () { - if (this.userReceivingGems.auth && this.userReceivingGems.auth.local && this.userReceivingGems.auth.local.username) { + if ( + this.userReceivingGems.auth + && this.userReceivingGems.auth.local + && this.userReceivingGems.auth.local.username + ) { return this.userReceivingGems.auth.local.username; } return this.userReceivingGems.profile.name; diff --git a/website/client/src/components/selectMembersModal.vue b/website/client/src/components/selectMembersModal.vue index 616db77973..d24e261d27 100644 --- a/website/client/src/components/selectMembersModal.vue +++ b/website/client/src/components/selectMembersModal.vue @@ -187,7 +187,7 @@ export default { this.members = this.$store.state.memberModalOptions.viewingMembers; } - if (!this.members || this.members.length === 0 && !this.groupId) { + if (!this.members || (this.members.length === 0 && !this.groupId)) { this.members = [this.user]; } }, diff --git a/website/client/src/components/settings/api.vue b/website/client/src/components/settings/api.vue index 1ea459e56e..02f9b692e2 100644 --- a/website/client/src/components/settings/api.vue +++ b/website/client/src/components/settings/api.vue @@ -86,18 +86,18 @@ export default { showApiToken: false, }; }, - mounted () { - window.addEventListener('message', this.receiveMessage, false); - }, - destroy () { - window.removeEventListener('message', this.receiveMessage); - }, computed: { ...mapState({ user: 'user.data', credentials: 'credentials' }), apiToken () { return this.credentials.API_TOKEN; }, }, + mounted () { + window.addEventListener('message', this.receiveMessage, false); + }, + destroy () { + window.removeEventListener('message', this.receiveMessage); + }, methods: { receiveMessage (eventFrom) { if (eventFrom.origin !== 'https://www.spritely.app') return; diff --git a/website/client/src/components/settings/promoCode.vue b/website/client/src/components/settings/promoCode.vue index 836699ff09..48e148cc55 100644 --- a/website/client/src/components/settings/promoCode.vue +++ b/website/client/src/components/settings/promoCode.vue @@ -45,11 +45,13 @@ export default { }, methods: { generateCodes () { - // $http.post(ApiUrl.get() + '/api/v2/coupons/generate/'+codes.event+'?count='+(codes.count || 1)) + // $http.post(ApiUrl.get() + '/api/v2/coupons/generate/ + // '+codes.event+'?count='+(codes.count || 1)) // .success(function(res,code){ // $scope._codes = {}; // if (code!==200) return; - // window.location.href = '/api/v2/coupons?limit='+codes.count+'&_id='+User.user._id+'&apiToken='+User.settings.auth.apiToken; + // window.location.href = '/api/v2/coupons?limit='+codes.count+'&_id='+User.user._id+ + // '&apiToken='+User.settings.auth.apiToken; // }) }, async enterCoupon () { diff --git a/website/client/src/components/settings/restoreModal.vue b/website/client/src/components/settings/restoreModal.vue index 73f1b84e46..bdbdb57e66 100644 --- a/website/client/src/components/settings/restoreModal.vue +++ b/website/client/src/components/settings/restoreModal.vue @@ -67,13 +67,13 @@ export default { }, }; }, + computed: { + ...mapState({ user: 'user.data' }), + }, mounted () { this.restoreValues.stats = clone(this.user.stats); this.restoreValues.achievements.streak = clone(this.user.achievements.streak); }, - computed: { - ...mapState({ user: 'user.data' }), - }, methods: { close () { this.$root.$emit('bv::hide::modal', 'restore'); diff --git a/website/client/src/components/settings/site.vue b/website/client/src/components/settings/site.vue index 88a077076e..f320576415 100644 --- a/website/client/src/components/settings/site.vue +++ b/website/client/src/components/settings/site.vue @@ -261,33 +261,6 @@ export default { usernameIssues: [], }; }, - mounted () { - this.SOCIAL_AUTH_NETWORKS = SUPPORTED_SOCIAL_NETWORKS; - // @TODO: We may need to request the party here - this.party = this.$store.state.party; - this.newDayStart = this.user.preferences.dayStart; - this.usernameUpdates.username = this.user.auth.local.username || null; - this.temporaryDisplayName = this.user.profile.name; - this.emailUpdates.newEmail = this.user.auth.local.email || null; - this.localAuth.username = this.user.auth.local.username || null; - this.soundIndex = 0; - hello.init({ - facebook: process.env.FACEBOOK_KEY, // eslint-disable-line no-process-env - google: process.env.GOOGLE_CLIENT_ID, // eslint-disable-line no-process-env - }, { - redirect_uri: '', // eslint-disable-line - }); - - const focusID = this.$route.query.focus; - if (focusID !== undefined && focusID !== null) { - this.$nextTick(() => { - const element = document.getElementById(focusID); - if (element !== undefined && element !== null) { - element.focus(); - } - }); - } - }, computed: { ...mapState({ user: 'user.data', @@ -358,6 +331,33 @@ export default { deep: true, }, }, + mounted () { + this.SOCIAL_AUTH_NETWORKS = SUPPORTED_SOCIAL_NETWORKS; + // @TODO: We may need to request the party here + this.party = this.$store.state.party; + this.newDayStart = this.user.preferences.dayStart; + this.usernameUpdates.username = this.user.auth.local.username || null; + this.temporaryDisplayName = this.user.profile.name; + this.emailUpdates.newEmail = this.user.auth.local.email || null; + this.localAuth.username = this.user.auth.local.username || null; + this.soundIndex = 0; + hello.init({ + facebook: process.env.FACEBOOK_KEY, // eslint-disable-line no-process-env + google: process.env.GOOGLE_CLIENT_ID, // eslint-disable-line no-process-env + }, { + redirect_uri: '', // eslint-disable-line + }); + + const focusID = this.$route.query.focus; + if (focusID !== undefined && focusID !== null) { + this.$nextTick(() => { + const element = document.getElementById(focusID); + if (element !== undefined && element !== null) { + element.focus(); + } + }); + } + }, methods: { validateDisplayName: debounce(function checkName (displayName) { if (displayName.length <= 1 || displayName === this.user.profile.name) { @@ -422,10 +422,12 @@ export default { return find(this.SOCIAL_AUTH_NETWORKS, network => { if (network.key !== networkKeyToCheck) { - if (this.user.auth.hasOwnProperty(network.key)) { + if (this.user.auth[network.key]) { return this.user.auth[network.key].id; } } + + return false; }); }, calculateNextCron () { @@ -442,7 +444,7 @@ export default { openDayStartModal () { const nextCron = this.calculateNextCron(); // @TODO: Add generic modal - if (!confirm(this.$t('sureChangeCustomDayStartTime', { time: nextCron }))) return; + if (!window.confirm(this.$t('sureChangeCustomDayStartTime', { time: nextCron }))) return; this.saveDayStart(); // $rootScope.openModal('change-day-start', { scope: $scope }); }, @@ -472,7 +474,7 @@ export default { }, async changeDisplayName (newName) { await axios.put('/api/v4/user/', { 'profile.name': newName }); - alert(this.$t('displayNameSuccess')); + window.alert(this.$t('displayNameSuccess')); this.user.profile.name = newName; this.temporaryDisplayName = newName; }, @@ -499,17 +501,17 @@ export default { window.location.href = '/'; }, async changeClassForUser (confirmationNeeded) { - if (confirmationNeeded && !confirm(this.$t('changeClassConfirmCost'))) return; + if (confirmationNeeded && !window.confirm(this.$t('changeClassConfirmCost'))) return; try { changeClass(this.user); await axios.post('/api/v4/user/change-class'); } catch (e) { - alert(e.message); + window.alert(e.message); } }, async addLocalAuth () { await axios.post('/api/v4/user/auth/local/register', this.localAuth); - alert(this.$t('addedLocalAuth')); + window.alert(this.$t('addedLocalAuth')); }, restoreEmptyUsername () { if (this.usernameUpdates.username.length < 1) { diff --git a/website/client/src/components/settings/subscription.vue b/website/client/src/components/settings/subscription.vue index df7750a4e2..908b5e7dc8 100644 --- a/website/client/src/components/settings/subscription.vue +++ b/website/client/src/components/settings/subscription.vue @@ -157,7 +157,8 @@ export default { purchasedPlanIdInfo () { if (!this.subscriptionBlocks[this.user.purchased.plan.planId]) { // @TODO: find which subs are in the common - // console.log(this.subscriptionBlocks[this.user.purchased.plan.planId]); // eslint-disable-line + // console.log(this.subscriptionBlocks + // [this.user.purchased.plan.planId]); // eslint-disable-line return { price: 0, months: 0, @@ -196,7 +197,8 @@ export default { return this.user.purchased.plan.customerId === 'group-plan'; }, hasConsecutiveSubscription () { - return Boolean(this.user.purchased.plan.consecutive.count) || Boolean(this.user.purchased.plan.consecutive.offset); + return Boolean(this.user.purchased.plan.consecutive.count) + || Boolean(this.user.purchased.plan.consecutive.offset); }, purchasedPlanExtraMonthsDetails () { return { diff --git a/website/client/src/components/settings/usernameForm.vue b/website/client/src/components/settings/usernameForm.vue index 92b84fb05b..a239c54818 100644 --- a/website/client/src/components/settings/usernameForm.vue +++ b/website/client/src/components/settings/usernameForm.vue @@ -100,6 +100,20 @@ import debounce from 'lodash/debounce'; import { mapState } from '@/libs/store'; export default { + props: { + avatarIntro: { + type: Boolean, + default: false, + }, + }, + data () { + return { + displayNameIssues: [], + temporaryDisplayName: '', + temporaryUsername: '', + usernameIssues: [], + }; + }, computed: { ...mapState({ user: 'user.data', @@ -125,13 +139,23 @@ export default { return this.usernameIssues.length === 0; }, }, - data () { - return { - displayNameIssues: [], - temporaryDisplayName: '', - temporaryUsername: '', - usernameIssues: [], - }; + watch: { + temporaryDisplayName: { + handler () { + this.validateDisplayName(this.temporaryDisplayName); + }, + deep: true, + }, + temporaryUsername: { + handler () { + this.validateUsername(this.temporaryUsername); + }, + deep: true, + }, + }, + mounted () { + this.temporaryDisplayName = this.user.profile.name; + this.temporaryUsername = this.user.auth.local.username; }, methods: { async close () { @@ -193,29 +217,5 @@ export default { }); }, 500), }, - watch: { - temporaryDisplayName: { - handler () { - this.validateDisplayName(this.temporaryDisplayName); - }, - deep: true, - }, - temporaryUsername: { - handler () { - this.validateUsername(this.temporaryUsername); - }, - deep: true, - }, - }, - mounted () { - this.temporaryDisplayName = this.user.profile.name; - this.temporaryUsername = this.user.auth.local.username; - }, - props: { - avatarIntro: { - type: Boolean, - default: false, - }, - }, }; diff --git a/website/client/src/components/shared/inventoryDrawer.vue b/website/client/src/components/shared/inventoryDrawer.vue index 481593f677..c13e87b011 100644 --- a/website/client/src/components/shared/inventoryDrawer.vue +++ b/website/client/src/components/shared/inventoryDrawer.vue @@ -145,10 +145,13 @@ export default { case 'food': return this.$t('noFoodAvailable'); case 'special': return this.$t('noSaddlesAvailable'); default: - // @TODO: Change any places using similar locales from `pets.json` and use these new locales from 'inventory.json' + // @TODO: Change any places using similar locales + // from `pets.json` and use these new locales from 'inventory.json' return this.$t('noItemsAvailableForType', { type: this.$t(`${type}ItemType`) }); } } + + return null; }, }, }; diff --git a/website/client/src/components/shops/balanceInfo.vue b/website/client/src/components/shops/balanceInfo.vue index 4d4414704b..265bd79294 100644 --- a/website/client/src/components/shops/balanceInfo.vue +++ b/website/client/src/components/shops/balanceInfo.vue @@ -90,7 +90,10 @@ export default { }); for (const currency of currencies) { - if (currency.type === this.currencyNeeded && !this.enoughCurrency(this.currencyNeeded, this.amountNeeded)) { + if ( + currency.type === this.currencyNeeded + && !this.enoughCurrency(this.currencyNeeded, this.amountNeeded) + ) { currency.notEnough = true; } } diff --git a/website/client/src/components/shops/buyModal.vue b/website/client/src/components/shops/buyModal.vue index 3a4756a257..25a5f40195 100644 --- a/website/client/src/components/shops/buyModal.vue +++ b/website/client/src/components/shops/buyModal.vue @@ -373,7 +373,8 @@ export default { }, gemsLeft () { if (!this.user.purchased.plan) return 0; - return planGemLimits.convCap + this.user.purchased.plan.consecutive.gemCapExtra - this.user.purchased.plan.gemsBought; + return planGemLimits.convCap + + this.user.purchased.plan.consecutive.gemCapExtra - this.user.purchased.plan.gemsBought; }, attemptingToPurchaseMoreGemsThanAreLeft () { if (this.item && this.item.key && this.item.key === 'gem' && this.selectedAmountToBuy > this.gemsLeft) return true; @@ -397,7 +398,8 @@ export default { this.$emit('change', $event); }, buyItem () { - // @TODO: I think we should buying to the items. Turn the items into classes, and use polymorphism + // @TODO: I think we should buying to the items. + // Turn the items into classes, and use polymorphism if (this.item.buy) { this.item.buy(); this.$emit('buyPressed', this.item); @@ -405,7 +407,10 @@ export default { return; } - if (this.item.pinType === 'premiumHatchingPotion' || this.item.pinType === 'eggs' && dropEggKeys.indexOf(this.item.key) === -1) { + if ( + this.item.pinType === 'premiumHatchingPotion' + || (this.item.pinType === 'eggs' && dropEggKeys.indexOf(this.item.key) === -1) + ) { let petsRemaining = 20 - this.selectedAmountToBuy; petsRemaining -= reduce(this.user.items.pets, (sum, petValue, petKey) => { if (petKey.indexOf(this.item.key) !== -1 && petValue > 0) return sum + 1; @@ -421,11 +426,17 @@ export default { petsRemaining -= this.user.items.eggs[this.item.key] || 0; } - if (petsRemaining < 0 && !confirm(this.$t('purchasePetItemConfirm', { itemText: this.item.text }))) return; + if ( + petsRemaining < 0 + && !window.confirm(this.$t('purchasePetItemConfirm', { itemText: this.item.text })) + ) return; } const shouldConfirmPurchase = this.item.currency === 'gems' || this.item.currency === 'hourglasses'; - if (shouldConfirmPurchase && !this.confirmPurchase(this.item.currency, this.item.value * this.selectedAmountToBuy)) { + if ( + shouldConfirmPurchase + && !this.confirmPurchase(this.item.currency, this.item.value * this.selectedAmountToBuy) + ) { return; } @@ -477,7 +488,7 @@ export default { return true; }, getAvatarOverrides (item) { - switch (item.purchaseType) { + switch (item.purchaseType) { // eslint-disable-line default-case case 'gear': return { [item.type]: item.key, @@ -489,7 +500,7 @@ export default { case 'mystery_set': { const gear = {}; - item.items.map(setItem => { + item.items.forEach(setItem => { gear[setItem.type] = setItem.key; }); diff --git a/website/client/src/components/shops/market/categoryItem.vue b/website/client/src/components/shops/market/categoryItem.vue index b6f466eaee..300b7de53a 100644 --- a/website/client/src/components/shops/market/categoryItem.vue +++ b/website/client/src/components/shops/market/categoryItem.vue @@ -45,7 +45,8 @@ export default { }, gemsLeft () { if (!this.user.purchased.plan) return 0; - return planGemLimits.convCap + this.user.purchased.plan.consecutive.gemCapExtra - this.user.purchased.plan.gemsBought; + return planGemLimits.convCap + + this.user.purchased.plan.consecutive.gemCapExtra - this.user.purchased.plan.gemsBought; }, }, }; diff --git a/website/client/src/components/shops/market/categoryRow.vue b/website/client/src/components/shops/market/categoryRow.vue index 1abd2329b2..91aab28eab 100644 --- a/website/client/src/components/shops/market/categoryRow.vue +++ b/website/client/src/components/shops/market/categoryRow.vue @@ -41,7 +41,8 @@ export default { }), gemsLeft () { if (!this.user.purchased.plan) return 0; - return planGemLimits.convCap + this.user.purchased.plan.consecutive.gemCapExtra - this.user.purchased.plan.gemsBought; + return planGemLimits.convCap + + this.user.purchased.plan.consecutive.gemCapExtra - this.user.purchased.plan.gemsBought; }, sortedMarketItems () { let result = _map(this.category.items, e => ({ @@ -64,7 +65,7 @@ export default { return true; }); - switch (this.sortBy) { + switch (this.sortBy) { // eslint-disable-line default-case case 'AZ': { result = _sortBy(result, ['text']); diff --git a/website/client/src/components/shops/market/equipmentSection.vue b/website/client/src/components/shops/market/equipmentSection.vue index 34d81d8aea..db6f52dad5 100644 --- a/website/client/src/components/shops/market/equipmentSection.vue +++ b/website/client/src/components/shops/market/equipmentSection.vue @@ -65,7 +65,10 @@ import svgHealer from '@/assets/svg/healer.svg'; import pinUtils from '../../../mixins/pinUtils'; -const sortGearTypes = ['sortByType', 'sortByPrice', 'sortByCon', 'sortByPer', 'sortByStr', 'sortByInt'].map(g => ({ id: g })); +const sortGearTypes = [ + 'sortByType', 'sortByPrice', 'sortByCon', + 'sortByPer', 'sortByStr', 'sortByInt', +].map(g => ({ id: g })); const sortGearTypeMap = { sortByType: 'type', diff --git a/website/client/src/components/shops/market/index.vue b/website/client/src/components/shops/market/index.vue index 5b557d1211..5b705076fc 100644 --- a/website/client/src/components/shops/market/index.vue +++ b/website/client/src/components/shops/market/index.vue @@ -189,11 +189,6 @@ export default { SelectMembersModal, }, mixins: [notifications, buyMixin, currencyMixin, inventoryUtils, pinUtils], - watch: { - searchText: _throttle(function throttleSearch () { - this.searchTextThrottled = this.searchText.toLowerCase(); - }, 250), - }, data () { return { viewOptions: { @@ -221,10 +216,6 @@ export default { broken: false, }; }, - async mounted () { - const worldState = await this.$store.dispatch('worldState:getWorldState'); - this.broken = worldState && worldState.worldBoss && worldState.worldBoss.extra && worldState.worldBoss.extra.worldDmg && worldState.worldBoss.extra.worldDmg.market; - }, computed: { ...mapState({ content: 'content', @@ -282,7 +273,7 @@ export default { }); } - categories.map(category => { + categories.forEach(category => { if (!this.viewOptions[category.identifier]) { this.$set(this.viewOptions, category.identifier, { selected: false, @@ -297,6 +288,17 @@ export default { return Object.values(this.viewOptions).some(g => g.selected); }, }, + watch: { + searchText: _throttle(function throttleSearch () { + this.searchTextThrottled = this.searchText.toLowerCase(); + }, 250), + }, + async mounted () { + const worldState = await this.$store.dispatch('worldState:getWorldState'); + this.broken = worldState && worldState.worldBoss + && worldState.worldBoss.extra && worldState.worldBoss.extra.worldDmg + && worldState.worldBoss.extra.worldDmg.market; + }, methods: { sellItem (itemScope) { this.$root.$emit('sellItem', itemScope); @@ -322,9 +324,12 @@ export default { }, inventoryDrawerErrorMessage (type) { if (!this.hasOwnedItemsForType(type)) { - // @TODO: Change any places using similar locales from `pets.json` and use these new locales from 'inventory.json' + // @TODO: Change any places using similar locales + // from `pets.json` and use these new locales from 'inventory.json' return this.$t('noItemsAvailableForType', { type: this.$t(`${type}ItemType`) }); } + + return null; }, itemSelected (item) { this.$root.$emit('buyModal::showItem', item); diff --git a/website/client/src/components/shops/market/keysToKennel.vue b/website/client/src/components/shops/market/keysToKennel.vue index 153e04ff1a..2b39a20892 100644 --- a/website/client/src/components/shops/market/keysToKennel.vue +++ b/website/client/src/components/shops/market/keysToKennel.vue @@ -84,7 +84,7 @@ export default { purchaseType: 'keys', pinType: 'keys', buy: () => { - if (!confirm(this.$t('releasePetsConfirm'))) return; + if (!window.confirm(this.$t('releasePetsConfirm'))) return; try { this.$store.dispatch('shops:releasePets', { user: this.user }); this.text(this.$t('releasePetsSuccess')); @@ -92,7 +92,7 @@ export default { // Reload because achievement is set in user.save instead of common window.location.reload(true); } catch (err) { - alert(err.message); + window.alert(err.message); } }, }, @@ -107,7 +107,7 @@ export default { purchaseType: 'keys', pinType: 'keys', buy: () => { - if (!confirm(this.$t('releaseMountsConfirm'))) return; + if (!window.confirm(this.$t('releaseMountsConfirm'))) return; try { this.$store.dispatch('shops:releaseMounts', { user: this.user }); this.text(this.$t('releaseMountsSuccess')); @@ -115,7 +115,7 @@ export default { // Reload because achievement is set in user.save instead of common window.location.reload(true); } catch (err) { - alert(err.message); + window.alert(err.message); } }, }, @@ -130,7 +130,7 @@ export default { purchaseType: 'keys', pinType: 'keys', buy: () => { - if (!confirm(this.$t('releaseBothConfirm'))) return; + if (!window.confirm(this.$t('releaseBothConfirm'))) return; try { this.$store.dispatch('shops:releaseBoth', { user: this.user }); this.text(this.$t('releaseBothSuccess')); @@ -138,7 +138,7 @@ export default { // Reload because achievement is set in user.save instead of common window.location.reload(true); } catch (err) { - alert(err.message); + window.alert(err.message); } }, }, diff --git a/website/client/src/components/shops/quests/buyQuestModal.vue b/website/client/src/components/shops/quests/buyQuestModal.vue index 5573d003e3..28019c3198 100644 --- a/website/client/src/components/shops/quests/buyQuestModal.vue +++ b/website/client/src/components/shops/quests/buyQuestModal.vue @@ -223,6 +223,17 @@ export default { questDialogContent, }, mixins: [buyMixin, currencyMixin, notifications, numberInvalid], + props: { + item: { + type: Object, + }, + priceType: { + type: String, + }, + withPin: { + type: Boolean, + }, + }, data () { return { icons: Object.freeze({ @@ -238,11 +249,6 @@ export default { selectedAmountToBuy: 1, }; }, - watch: { - item: function itemChanged () { - this.isPinned = this.item && this.item.pinned; - }, - }, computed: { ...mapState({ content: 'content', @@ -265,6 +271,11 @@ export default { return this.icons.gem; }, }, + watch: { + item: function itemChanged () { + this.isPinned = this.item && this.item.pinned; + }, + }, methods: { onChange ($event) { this.selectedAmountToBuy = 1; @@ -324,16 +335,5 @@ export default { this.$root.$emit('bv::show::modal', 'buy-gems'); }, }, - props: { - item: { - type: Object, - }, - priceType: { - type: String, - }, - withPin: { - type: Boolean, - }, - }, }; diff --git a/website/client/src/components/shops/quests/index.vue b/website/client/src/components/shops/quests/index.vue index be963d5a3b..56dd8711b6 100644 --- a/website/client/src/components/shops/quests/index.vue +++ b/website/client/src/components/shops/quests/index.vue @@ -367,11 +367,6 @@ export default { QuestInfo, }, mixins: [buyMixin, currencyMixin, pinUtils], - watch: { - searchText: _throttle(function throttleSearch () { - this.searchTextThrottled = this.searchText.toLowerCase(); - }, 250), - }, data () { return { viewOptions: {}, @@ -394,10 +389,6 @@ export default { broken: false, }; }, - async mounted () { - const worldState = await this.$store.dispatch('worldState:getWorldState'); - this.broken = worldState && worldState.worldBoss && worldState.worldBoss.extra && worldState.worldBoss.extra.worldDmg && worldState.worldBoss.extra.worldDmg.quests; - }, computed: { ...mapState({ content: 'content', @@ -410,7 +401,7 @@ export default { }, categories () { if (this.shop.categories) { - this.shop.categories.map(category => { + this.shop.categories.forEach(category => { this.$set(this.viewOptions, category.identifier, { selected: false, }); @@ -425,6 +416,16 @@ export default { return Object.values(this.viewOptions).some(g => g.selected); }, }, + watch: { + searchText: _throttle(function throttleSearch () { + this.searchTextThrottled = this.searchText.toLowerCase(); + }, 250), + }, + async mounted () { + const worldState = await this.$store.dispatch('worldState:getWorldState'); + this.broken = worldState && worldState.worldBoss && worldState.worldBoss.extra + && worldState.worldBoss.extra.worldDmg && worldState.worldBoss.extra.worldDmg.quests; + }, methods: { questItems (category, sortBy, searchBy, hideLocked, hidePinned) { let result = _map(category.items, e => ({ @@ -443,7 +444,7 @@ export default { return !searchBy || i.text.toLowerCase().indexOf(searchBy) !== -1; }); - switch (sortBy) { + switch (sortBy) { // eslint-disable-line default-case case 'AZ': { result = _sortBy(result, ['text']); diff --git a/website/client/src/components/shops/quests/questInfo.vue b/website/client/src/components/shops/quests/questInfo.vue index 0609ae0b36..a110d296f5 100644 --- a/website/client/src/components/shops/quests/questInfo.vue +++ b/website/client/src/components/shops/quests/questInfo.vue @@ -132,7 +132,7 @@ export default { const result = []; const { difficulty } = this; - for (let i = 1; i <= 4; i++) { + for (let i = 1; i <= 4; i += 1) { const diff = difficulty - i; if (diff >= 0) { diff --git a/website/client/src/components/shops/seasonal/index.vue b/website/client/src/components/shops/seasonal/index.vue index 5dec3bef91..6c570fcc6e 100644 --- a/website/client/src/components/shops/seasonal/index.vue +++ b/website/client/src/components/shops/seasonal/index.vue @@ -331,11 +331,6 @@ export default { Avatar, }, mixins: [buyMixin, currencyMixin, pinUtils], - watch: { - searchText: _throttle(function throttleSearch () { - this.searchTextThrottled = this.searchText.toLowerCase(); - }, 250), - }, data () { return { viewOptions: {}, @@ -372,10 +367,6 @@ export default { broken: false, }; }, - async mounted () { - const worldState = await this.$store.dispatch('worldState:getWorldState'); - this.broken = worldState && worldState.worldBoss && worldState.worldBoss.extra && worldState.worldBoss.extra.worldDmg && worldState.worldBoss.extra.worldDmg.seasonalShop; - }, computed: { ...mapState({ content: 'content', @@ -389,18 +380,19 @@ export default { seasonal () { // vue subscriptions, don't remove - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line - const myUserVersion = this.user._v; // eslint-disable-line + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + const myUserVersion = this.user._v; // eslint-disable-line const seasonal = shops.getSeasonalShop(this.user); - const itemsNotOwned = seasonal.featured.items.filter(item => !this.user.items.gear.owned[item.key]); + const itemsNotOwned = seasonal.featured.items + .filter(item => !this.user.items.gear.owned[item.key]); seasonal.featured.items = itemsNotOwned; // If we are out of gear, show the spells // @TODO: add dates to check instead? if (seasonal.featured.items.length === 0) { - this.featuredGearBought = true; // eslint-disable-line vue/no-side-effects-in-computed-properties + this.featuredGearBought = true; // eslint-disable-line vue/no-side-effects-in-computed-properties, max-len if (seasonal.categories.length > 0) { seasonal.featured.items = seasonal.featured.items.concat(seasonal.categories[0].items); } @@ -444,6 +436,16 @@ export default { return Object.values(this.viewOptions).some(g => g.selected); }, }, + watch: { + searchText: _throttle(function throttleSearch () { + this.searchTextThrottled = this.searchText.toLowerCase(); + }, 250), + }, + async mounted () { + const worldState = await this.$store.dispatch('worldState:getWorldState'); + this.broken = worldState && worldState.worldBoss && worldState.worldBoss.extra + && worldState.worldBoss.extra.worldDmg && worldState.worldBoss.extra.worldDmg.seasonalShop; + }, created () { this.$root.$on('buyModal::boughtItem', () => { this.backgroundUpdate = new Date(); @@ -477,7 +479,7 @@ export default { return !searchBy || i.text.toLowerCase().indexOf(searchBy) !== -1; }); - switch (sortBy) { + switch (sortBy) { // eslint-disable-line default-case case 'AZ': { result = _sortBy(result, ['text']); diff --git a/website/client/src/components/shops/timeTravelers/index.vue b/website/client/src/components/shops/timeTravelers/index.vue index 7507ef738d..91fda43f44 100644 --- a/website/client/src/components/shops/timeTravelers/index.vue +++ b/website/client/src/components/shops/timeTravelers/index.vue @@ -274,11 +274,6 @@ export default { BuyQuestModal, }, mixins: [pinUtils], - watch: { - searchText: _throttle(function throttleSearch () { - this.searchTextThrottled = this.searchText.toLowerCase(); - }, 250), - }, data () { return { viewOptions: {}, @@ -321,8 +316,9 @@ export default { categories () { const apiCategories = this.shop.categories; - // FIX ME Refactor the apiCategories Hack to force update for now until we restructure the data - let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line + // FIX ME Refactor the apiCategories Hack to + // force update for now until we restructure the data + let backgroundUpdate = this.backgroundUpdate; // eslint-disable-line const normalGroups = _filter(apiCategories, c => c.identifier === 'mounts' || c.identifier === 'pets' || c.identifier === 'quests'); @@ -343,7 +339,7 @@ export default { normalGroups.push(setCategory); - normalGroups.map(category => { + normalGroups.forEach(category => { this.$set(this.viewOptions, category.identifier, { selected: false, }); @@ -355,6 +351,11 @@ export default { return Object.values(this.viewOptions).some(g => g.selected); }, }, + watch: { + searchText: _throttle(function throttleSearch () { + this.searchTextThrottled = this.searchText.toLowerCase(); + }, 250), + }, created () { this.$root.$on('buyModal::boughtItem', () => { this.backgroundUpdate = new Date(); @@ -378,7 +379,7 @@ export default { return !searchBy || i.text.toLowerCase().indexOf(searchBy) !== -1; }); - switch (sortBy) { + switch (sortBy) { // eslint-disable-line default-case case 'AZ': { result = _sortBy(result, ['text']); diff --git a/website/client/src/components/snackbars/notification.vue b/website/client/src/components/snackbars/notification.vue index 24be51a77c..adedd06cc6 100644 --- a/website/client/src/components/snackbars/notification.vue +++ b/website/client/src/components/snackbars/notification.vue @@ -144,7 +144,9 @@ export default { if (this.notification.type === 'gp') localeKey += 'Gold'; if (this.notification.type === 'streak') localeKey = 'streakCoins'; return this.$t(localeKey); - // This requires eight translatable strings, but that gives the translators the most flexibility for matching gender/number and for using idioms for lost/spent/used/gained. + // This requires eight translatable strings, but that gives the + // translators the most flexibility for matching gender/number + // and for using idioms for lost/spent/used/gained. }, negative () { return this.notification.sign === '-' ? 'negative' : 'positive'; @@ -159,7 +161,8 @@ export default { }, }, created () { - const timeout = this.notification.hasOwnProperty('timeout') ? this.notification.timeout : true; + const timeout = this.notification && this.notification.timeout + ? this.notification.timeout : true; if (timeout) { let delay = this.notification.delay || 1500; delay += this.$store.state.notificationStore.length * 1000; diff --git a/website/client/src/components/static/faq.vue b/website/client/src/components/static/faq.vue index 251cb5d284..ab2b5cf803 100644 --- a/website/client/src/components/static/faq.vue +++ b/website/client/src/components/static/faq.vue @@ -90,7 +90,7 @@ export default { handleClick (e) { if (!e) return; const heading = e.target.nextElementSibling.id; - history.pushState({}, heading, `#${heading}`); + window.history.pushState({}, heading, `#${heading}`); }, }, }; diff --git a/website/client/src/components/static/staticWrapper.vue b/website/client/src/components/static/staticWrapper.vue index c492eea6d8..c40679bce6 100644 --- a/website/client/src/components/static/staticWrapper.vue +++ b/website/client/src/components/static/staticWrapper.vue @@ -170,7 +170,7 @@ export default { return this.$route.name !== 'news'; }, footerId () { - if (this.$route.name === 'plans') return; + if (this.$route.name === 'plans') return null; return 'purple-footer'; }, }, diff --git a/website/client/src/components/tasks/approvalFooter.vue b/website/client/src/components/tasks/approvalFooter.vue index 9c4809fb84..1d6eec8b33 100644 --- a/website/client/src/components/tasks/approvalFooter.vue +++ b/website/client/src/components/tasks/approvalFooter.vue @@ -53,7 +53,8 @@ export default { computed: { ...mapState({ user: 'user.data' }), userIsAssigned () { - return this.task.group.assignedUsers && this.task.group.assignedUsers.indexOf(this.user._id) !== -1; + return this.task.group.assignedUsers + && this.task.group.assignedUsers.indexOf(this.user._id) !== -1; }, message () { const { assignedUsers } = this.task.group; @@ -81,11 +82,19 @@ export default { return this.$t('taskIsUnassigned'); }, userIsManager () { - if (this.group && (this.group.leader.id === this.user._id || this.group.managers[this.user._id])) return true; + if ( + this.group + && (this.group.leader.id === this.user._id || this.group.managers[this.user._id]) + ) return true; return false; }, approvalRequested () { - if (this.task.approvals && this.task.approvals.length === 1 || this.task.group && this.task.group.approval && this.task.group.approval.requested) return true; + if ( + (this.task.approvals && this.task.approvals.length === 1) + || (this.task.group && this.task.group.approval && this.task.group.approval.requested) + ) { + return true; + } return false; }, multipleApprovalsRequested () { @@ -109,7 +118,7 @@ export default { this.sync(); }, async unassign () { - if (!confirm(this.$t('confirmUnClaim'))) return; + if (!window.confirm(this.$t('confirmUnClaim'))) return; let taskId = this.task._id; // If we are on the user task @@ -136,7 +145,7 @@ export default { this.task.approvals.splice(0, 1); }, needsWork () { - if (!confirm(this.$t('confirmNeedsWork'))) return; + if (!window.confirm(this.$t('confirmNeedsWork'))) return; const userIdNeedsMoreWork = this.task.group.assignedUsers[0]; this.$store.dispatch('tasks:needsWork', { taskId: this.task._id, diff --git a/website/client/src/components/tasks/approvalHeader.vue b/website/client/src/components/tasks/approvalHeader.vue index fa65fbb956..81578e9329 100644 --- a/website/client/src/components/tasks/approvalHeader.vue +++ b/website/client/src/components/tasks/approvalHeader.vue @@ -34,19 +34,24 @@ export default { message () { const approvals = this.task.approvals || []; const approvalsLength = approvals.length; - const userIsRequesting = approvals.findIndex(approval => approval.userId.id === this.user._id) !== -1; + const userIsRequesting = approvals + .findIndex(approval => approval.userId.id === this.user._id) !== -1; if (approvalsLength === 1 && !userIsRequesting) { return this.$t('userRequestsApproval', { userName: approvals[0].userId.profile.name }); } if (approvalsLength > 1 && !userIsRequesting) { return this.$t('userCountRequestsApproval', { userCount: approvalsLength }); - } if (approvalsLength === 1 && userIsRequesting || this.task.group.approval && this.task.group.approval.requested && !this.task.group.approval.approved) { + } if ( + (approvalsLength === 1 && userIsRequesting) + || (this.task.group.approval + && this.task.group.approval.requested && !this.task.group.approval.approved)) { return this.$t('youAreRequestingApproval'); } return null; }, userIsAdmin () { - return this.group && (this.group.leader.id === this.user._id || this.group.managers[this.user._id]); + return this.group + && (this.group.leader.id === this.user._id || this.group.managers[this.user._id]); }, }, }; diff --git a/website/client/src/components/tasks/approvalModal.vue b/website/client/src/components/tasks/approvalModal.vue index e98bcfe812..7d297bb005 100644 --- a/website/client/src/components/tasks/approvalModal.vue +++ b/website/client/src/components/tasks/approvalModal.vue @@ -33,7 +33,7 @@ export default { this.task.approvals.splice(index, 1); }, needsWork (index) { - if (!confirm(this.$t('confirmNeedsWork'))) return; + if (!window.confirm(this.$t('confirmNeedsWork'))) return; const userIdNeedsMoreWork = this.task.group.assignedUsers[index]; this.$store.dispatch('tasks:needsWork', { taskId: this.task._id, diff --git a/website/client/src/components/tasks/brokenTaskModal.vue b/website/client/src/components/tasks/brokenTaskModal.vue index ddde351411..2952e24f38 100644 --- a/website/client/src/components/tasks/brokenTaskModal.vue +++ b/website/client/src/components/tasks/brokenTaskModal.vue @@ -81,7 +81,7 @@ export default { this.close(); }, removeTask () { - if (!confirm('Are you sure you want to delete this task?')) return; + if (!window.confirm('Are you sure you want to delete this task?')) return; this.destroyTask(this.brokenChallengeTask); this.close(); }, diff --git a/website/client/src/components/tasks/clearCompletedTodos.vue b/website/client/src/components/tasks/clearCompletedTodos.vue index a2239dd404..64f5df0826 100644 --- a/website/client/src/components/tasks/clearCompletedTodos.vue +++ b/website/client/src/components/tasks/clearCompletedTodos.vue @@ -25,7 +25,7 @@ export default { methods: { clearTodos () { - if (!confirm(this.$t('clearCompletedConfirm'))) return; + if (!window.confirm(this.$t('clearCompletedConfirm'))) return; this.$store.dispatch('tasks:clearCompletedTodos'); }, }, diff --git a/website/client/src/components/tasks/column.vue b/website/client/src/components/tasks/column.vue index 9600c88370..64b06cd3d5 100644 --- a/website/client/src/components/tasks/column.vue +++ b/website/client/src/components/tasks/column.vue @@ -347,14 +347,6 @@ export default { dragging: false, }; }, - created () { - // Set Task Column Label - this.typeLabel = getTypeLabel(this.type); - // Get Category Filter Labels - this.typeFilters = getFilterLabels(this.type); - // Set default filter for task column - this.activateFilter(this.type); - }, computed: { ...mapState({ user: 'user.data', @@ -409,7 +401,8 @@ export default { return this.isUser === true && this.type === 'reward' && this.activeFilter.label !== 'custom'; }, initialColumnDescription () { - // Show the column description in the middle only if there are no elements (tasks or in app items) + // Show the column description in the middle only + // if there are no elements (tasks or in app items) if (this.hasRewardsList) { if (this.inAppRewards && this.inAppRewards.length >= 0) return false; } @@ -430,7 +423,8 @@ export default { if (this.activeFilter.label === 'due') { return this.taskList.length; } if (this.activeFilter.label === 'all') { - return this.taskList.reduce((count, t) => (!t.completed && shouldDo(new Date(), t, this.getUserPreferences) ? count + 1 : count), 0); + return this.taskList + .reduce((count, t) => (!t.completed && shouldDo(new Date(), t, this.getUserPreferences) ? count + 1 : count), 0); } } @@ -449,6 +443,14 @@ export default { if (!newValue) this.quickAddRows = 1; }, }, + created () { + // Set Task Column Label + this.typeLabel = getTypeLabel(this.type); + // Get Category Filter Labels + this.typeFilters = getFilterLabels(this.type); + // Set default filter for task column + this.activateFilter(this.type); + }, mounted () { this.setColumnBackgroundVisibility(); @@ -538,7 +540,7 @@ export default { quickAdd (ev) { // Add a new line if Shift+Enter Pressed if (ev.shiftKey) { - this.quickAddRows++; + this.quickAddRows += 1; return true; } @@ -557,6 +559,7 @@ export default { this.quickAddRows = 1; this.createTask(tasks); this.$refs.quickAdd.blur(); + return true; }, editTask (task) { this.$emit('editTask', task); @@ -571,11 +574,14 @@ export default { } } - // the only time activateFilter is called with filter==='' is when the component is first created - // this can be used to check If the user has set 'due' as default filter for daily - // and set the filter as 'due' only when the component first loads and not on subsequent reloads. + // the only time activateFilter is called with filter==='' + // is when the component is first created + // this can be used to check If the user has set 'due' + // as default filter for daily + // and set the filter as 'due' only when the component first + // loads and not on subsequent reloads. if (type === 'daily' && filter === '' && this.user.preferences.dailyDueDefaultView) { - filter = 'due'; + filter = 'due'; // eslint-disable-line no-param-reassign } this.activeFilter = getActiveFilter(type, filter); diff --git a/website/client/src/components/tasks/spells.vue b/website/client/src/components/tasks/spells.vue index 3b8cd16bea..74970622d3 100644 --- a/website/client/src/components/tasks/spells.vue +++ b/website/client/src/components/tasks/spells.vue @@ -201,36 +201,44 @@ export default { potionClickMode: false, }; }, - mounted () { - // @TODO: should we abstract the drawer state/local store to a library and mixing combo? We use a similar pattern in equipment - const spellDrawerState = getLocalSetting(CONSTANTS.keyConstants.SPELL_DRAWER_STATE); - if (spellDrawerState === CONSTANTS.drawerStateValues.DRAWER_CLOSED) { - this.$store.state.spellOptions.spellDrawOpen = false; - } - }, computed: { ...mapState({ user: 'user.data' }), openStatus () { return this.$store.state.spellOptions.spellDrawOpen ? 1 : 0; }, }, + mounted () { + // @TODO: should we abstract the drawer state/local + // store to a library and mixing combo? We use a similar pattern in equipment + const spellDrawerState = getLocalSetting(CONSTANTS.keyConstants.SPELL_DRAWER_STATE); + if (spellDrawerState === CONSTANTS.drawerStateValues.DRAWER_CLOSED) { + this.$store.state.spellOptions.spellDrawOpen = false; + } + }, methods: { drawerToggled (newState) { this.$store.state.spellOptions.spellDrawOpen = newState; if (newState) { - setLocalSetting(CONSTANTS.keyConstants.SPELL_DRAWER_STATE, CONSTANTS.drawerStateValues.DRAWER_OPEN); + setLocalSetting( + CONSTANTS.keyConstants.SPELL_DRAWER_STATE, + CONSTANTS.drawerStateValues.DRAWER_OPEN, + ); return; } - setLocalSetting(CONSTANTS.keyConstants.SPELL_DRAWER_STATE, CONSTANTS.drawerStateValues.DRAWER_CLOSED); + setLocalSetting( + CONSTANTS.keyConstants.SPELL_DRAWER_STATE, + CONSTANTS.drawerStateValues.DRAWER_CLOSED, + ); }, spellDisabled (skill) { if (skill === 'frost' && this.user.stats.buffs.streaks) { return true; } // @TODO: Implement - // } else if (skill === 'stealth' && this.user.stats.buffs.stealth >= this.user.dailys.length) { + // } else if (skill === 'stealth' && this.user.stats.buffs.stealth + // >= this.user.dailys.length) { // return true; // } diff --git a/website/client/src/components/tasks/task.vue b/website/client/src/components/tasks/task.vue index 21b5b13a60..20bd02692b 100644 --- a/website/client/src/components/tasks/task.vue +++ b/website/client/src/components/tasks/task.vue @@ -631,7 +631,8 @@ export default { }, checklistProgress () { const totalItems = this.task.checklist.length; - const completedItems = this.task.checklist.reduce((total, item) => (item.completed ? total + 1 : total), 0); + const completedItems = this.task.checklist + .reduce((total, item) => (item.completed ? total + 1 : total), 0); return `${completedItems}/${totalItems}`; }, leftControl () { @@ -734,7 +735,7 @@ export default { this.$emit('moveTo', this.task, 'bottom'); }, destroy () { - if (!confirm(this.$t('sureDelete'))) return; + if (!window.confirm(this.$t('sureDelete'))) return; this.destroyTask(this.task); this.$emit('taskDestroyed', this.task); }, diff --git a/website/client/src/components/tasks/taskModal.vue b/website/client/src/components/tasks/taskModal.vue index fea4551a61..e5896b73ed 100644 --- a/website/client/src/components/tasks/taskModal.vue +++ b/website/client/src/components/tasks/taskModal.vue @@ -724,20 +724,6 @@ export default { calendarHighlights: { dates: [new Date()] }, }; }, - watch: { - task () { - this.syncTask(); - }, - 'task.startDate': function () { - this.calculateMonthlyRepeatDays(); - }, - 'task.frequency': function () { - this.calculateMonthlyRepeatDays(); - }, - }, - mounted () { - this.showAdvancedOptions = !this.user.preferences.advancedCollapsed; - }, computed: { ...mapGetters({ getTaskClasses: 'tasks:getTaskClasses', @@ -767,7 +753,8 @@ export default { }, isOriginalChallengeTask () { const isUserChallenge = Boolean(this.task.userId); - return !isUserChallenge && (this.challengeId || this.task.challenge && this.task.challenge.id); + return !isUserChallenge + && (this.challengeId || (this.task.challenge && this.task.challenge.id)); }, canDelete () { return this.purpose !== 'create' && this.canDeleteTask(this.task); @@ -817,6 +804,20 @@ export default { return this.selectedTags.slice(this.maxTags); }, }, + watch: { + task () { + this.syncTask(); + }, + 'task.startDate': function taskStartDate () { + this.calculateMonthlyRepeatDays(); + }, + 'task.frequency': function taskFrequency () { + this.calculateMonthlyRepeatDays(); + }, + }, + mounted () { + this.showAdvancedOptions = !this.user.preferences.advancedCollapsed; + }, created () { document.addEventListener('keyup', this.handleEsc); }, @@ -840,11 +841,16 @@ export default { this.memberNamesById[member._id] = member.profile.name; }); this.assignedMembers = []; - if (this.task.group && this.task.group.assignedUsers) this.assignedMembers = this.task.group.assignedUsers; - if (this.task.group) this.sharedCompletion = this.task.group.sharedCompletion || 'singleCompletion'; + if (this.task.group && this.task.group.assignedUsers) { + this.assignedMembers = this.task.group.assignedUsers; + } + if (this.task.group) { + this.sharedCompletion = this.task.group.sharedCompletion || 'singleCompletion'; + } } - // @TODO: This whole component is mutating a prop and that causes issues. We need to not copy the prop similar to group modals + // @TODO: This whole component is mutating a prop + // and that causes issues. We need to not copy the prop similar to group modals if (this.task) this.checklist = clone(this.task.checklist); }, async handleOpen () { @@ -913,7 +919,7 @@ export default { const shortDay = this.dayMapping[dayOfWeek]; task.daysOfMonth = []; task.weeksOfMonth = [week]; - for (const key in task.repeat) { + for (const key of Object.keys(task.repeat)) { task.repeat[key] = false; } task.repeat[shortDay] = true; @@ -962,7 +968,7 @@ export default { this.$root.$emit('bv::hide::modal', 'task-modal'); }, destroy () { - if (!confirm(this.$t('sureDelete'))) return; + if (!window.confirm(this.$t('sureDelete'))) return; this.destroyTask(this.task); this.$emit('taskDestroyed', this.task); this.$root.$emit('bv::hide::modal', 'task-modal'); diff --git a/website/client/src/components/ui/drawerSlider.vue b/website/client/src/components/ui/drawerSlider.vue index 1aaddab27d..e174eff6fa 100644 --- a/website/client/src/components/ui/drawerSlider.vue +++ b/website/client/src/components/ui/drawerSlider.vue @@ -162,14 +162,14 @@ export default { methods: { shiftLeft () { if (this.pointer < this.items.length - 1) { - this.pointer++; + this.pointer += 1; } else { this.pointer = 0; } }, shiftRight () { if (this.pointer > 0) { - this.pointer--; + this.pointer -= 1; } else { this.pointer = this.items.length - 1; } diff --git a/website/client/src/components/userMenu/achievements.vue b/website/client/src/components/userMenu/achievements.vue index 0424b94e5b..6be71459d7 100644 --- a/website/client/src/components/userMenu/achievements.vue +++ b/website/client/src/components/userMenu/achievements.vue @@ -62,11 +62,11 @@ export default { content: Content, }; }, - mounted () { - this.achievements = achievementsLib.getAchievementsForProfile(this.user); - }, computed: { ...mapState({ user: 'user.data' }), }, + mounted () { + this.achievements = achievementsLib.getAchievementsForProfile(this.user); + }, }; diff --git a/website/client/src/components/userMenu/inbox.vue b/website/client/src/components/userMenu/inbox.vue index d0727ddb51..4846ea3d3b 100644 --- a/website/client/src/components/userMenu/inbox.vue +++ b/website/client/src/components/userMenu/inbox.vue @@ -299,37 +299,6 @@ export default { updateConversionsCounter: 0, }; }, - mounted () { - this.$root.$on('habitica::new-inbox-message', data => { - this.$root.$emit('bv::show::modal', 'inbox-modal'); - - // Wait for messages to be loaded - const unwatchLoaded = this.$watch('loaded', loaded => { - if (!loaded) return; - - const conversation = this.conversations.find(convo => convo.key === data.userIdToMessage); - if (loaded) setImmediate(() => unwatchLoaded()); - - if (conversation) { - this.selectConversation(data.userIdToMessage); - return; - } - - this.initiatedConversation = { - uuid: data.userIdToMessage, - user: data.displayName, - username: data.username, - backer: data.backer, - contributor: data.contributor, - }; - - this.selectConversation(data.userIdToMessage); - }, { immediate: true }); - }); - }, - destroyed () { - this.$root.$off('habitica::new-inbox-message'); - }, computed: { ...mapState({ user: 'user.data' }), canLoadMore () { @@ -427,6 +396,37 @@ export default { }; }, }, + mounted () { + this.$root.$on('habitica::new-inbox-message', data => { + this.$root.$emit('bv::show::modal', 'inbox-modal'); + + // Wait for messages to be loaded + const unwatchLoaded = this.$watch('loaded', loaded => { + if (!loaded) return; + + const conversation = this.conversations.find(convo => convo.key === data.userIdToMessage); + if (loaded) setImmediate(() => unwatchLoaded()); + + if (conversation) { + this.selectConversation(data.userIdToMessage); + return; + } + + this.initiatedConversation = { + uuid: data.userIdToMessage, + user: data.displayName, + username: data.username, + backer: data.backer, + contributor: data.contributor, + }; + + this.selectConversation(data.userIdToMessage); + }, { immediate: true }); + }); + }, + destroyed () { + this.$root.$off('habitica::new-inbox-message'); + }, methods: { async onModalShown () { this.loaded = false; @@ -507,7 +507,10 @@ export default { }); // Remove the placeholder message - if (this.initiatedConversation && this.initiatedConversation.uuid === this.selectedConversation.key) { + if ( + this.initiatedConversation && + this.initiatedConversation.uuid === this.selectedConversation.key + ) { this.loadedConversations.unshift(this.initiatedConversation); this.initiatedConversation = null; } @@ -529,7 +532,7 @@ export default { const messageToReset = messages[messages.length - 1]; messageToReset.id = newMessage.id; // just set the id, all other infos already set Object.assign(messages[messages.length - 1], messageToReset); - this.updateConversionsCounter++; + this.updateConversionsCounter += 1; }); this.newMessage = ''; @@ -542,7 +545,7 @@ export default { if (isNPC) { return this.icons.tierNPC; } - if (!message.contributor) return; + if (!message.contributor) return null; return this.icons[`tier${message.contributor.level}`]; }, removeTags (html) { @@ -551,7 +554,7 @@ export default { return tmp.textContent || tmp.innerText || ''; }, parseMarkdown (text) { - if (!text) return; + if (!text) return null; return habiticaMarkdown.render(String(text)); }, infiniteScrollTrigger () { diff --git a/website/client/src/components/userMenu/profile.vue b/website/client/src/components/userMenu/profile.vue index e97e872791..47b5b7ad01 100644 --- a/website/client/src/components/userMenu/profile.vue +++ b/website/client/src/components/userMenu/profile.vue @@ -463,10 +463,12 @@ export default { flatGear: 'content.gear.flat', }), userJoinedDate () { - return moment(this.user.auth.timestamps.created).format(this.userLoggedIn.preferences.dateFormat.toUpperCase()); + return moment(this.user.auth.timestamps.created) + .format(this.userLoggedIn.preferences.dateFormat.toUpperCase()); }, userLastLoggedIn () { - return moment(this.user.auth.timestamps.loggedin).format(this.userLoggedIn.preferences.dateFormat.toUpperCase()); + return moment(this.user.auth.timestamps.loggedin) + .format(this.userLoggedIn.preferences.dateFormat.toUpperCase()); }, equippedItems () { return this.user.items.gear.equipped; @@ -570,7 +572,7 @@ export default { if (!currentLoginDay) return 0; const previousRewardDay = currentLoginDay.prevRewardKey; const { nextRewardAt } = currentLoginDay; - return (this.user.loginIncentives - previousRewardDay) / (nextRewardAt - previousRewardDay) * 100; + return ((this.user.loginIncentives - previousRewardDay) / (nextRewardAt - previousRewardDay)) * 100; }, save () { const values = {}; diff --git a/website/client/src/components/userMenu/profileStats.vue b/website/client/src/components/userMenu/profileStats.vue index 8c55dd7ad5..3b62593825 100644 --- a/website/client/src/components/userMenu/profileStats.vue +++ b/website/client/src/components/userMenu/profileStats.vue @@ -303,11 +303,11 @@ export default { }, allocate (stat) { if (this.pointsRemaining === 0) return; - this.statUpdates[stat]++; + this.statUpdates[stat] += 1; }, deallocate (stat) { if (this.statUpdates[stat] === 0) return; - this.statUpdates[stat]--; + this.statUpdates[stat] -= 1; }, async saveAttributes () { this.loading = true; diff --git a/website/client/src/components/userMenu/stats.vue b/website/client/src/components/userMenu/stats.vue index 66ffd0fa71..38a40c5411 100644 --- a/website/client/src/components/userMenu/stats.vue +++ b/website/client/src/components/userMenu/stats.vue @@ -246,21 +246,23 @@ export default { methods: { formatAnimal (animalName, type) { if (type === 'pet') { - if (Content.petInfo.hasOwnProperty(animalName)) { + if (Content.petInfo[animalName]) { return Content.petInfo[animalName].text(); } return this.$t('noActivePet'); } if (type === 'mount') { - if (Content.mountInfo.hasOwnProperty(animalName)) { + if (Content.mountInfo[animalName]) { return Content.mountInfo[animalName].text(); } return this.$t('noActiveMount'); } + + return null; }, formatBackground (background) { const bg = Content.appearances.background; - if (bg.hasOwnProperty(background)) { + if (bg[background]) { return `${bg[background].text()} (${this.$t(bg[background].set.text)})`; } return window.env.t('noBackground'); diff --git a/website/client/src/directives/directive.common.js b/website/client/src/directives/directive.common.js index 355e539d05..fb0f9a7b28 100644 --- a/website/client/src/directives/directive.common.js +++ b/website/client/src/directives/directive.common.js @@ -1,6 +1,9 @@ // https://stackoverflow.com/a/40720172/1298154 export const emit = (vnode, emitName, data) => { // eslint-disable-line import/prefer-default-export - const handlers = vnode.data && vnode.data.on || vnode.componentOptions && vnode.componentOptions.listeners; + const handlers = (vnode.data + && vnode.data.on) + || (vnode.componentOptions + && vnode.componentOptions.listeners); if (handlers && handlers[emitName]) { handlers[emitName].fns(data); diff --git a/website/client/src/libs/store/helpers/filterTasks.js b/website/client/src/libs/store/helpers/filterTasks.js index 2068bfadb5..caac6ebb9d 100644 --- a/website/client/src/libs/store/helpers/filterTasks.js +++ b/website/client/src/libs/store/helpers/filterTasks.js @@ -47,7 +47,7 @@ function filterLabel (filterList) { return type => { const filterListByType = filterList[type].filters; const filterListOfLabels = new Array(filterListByType.length); - filterListByType.forEach(({ label }, i) => filterListOfLabels[i] = label); + filterListByType.forEach(({ label }, i) => { filterListOfLabels[i] = label; }); return filterListOfLabels; }; diff --git a/website/client/src/libs/store/helpers/internals.js b/website/client/src/libs/store/helpers/internals.js index 2c37f4869a..c846ae0672 100644 --- a/website/client/src/libs/store/helpers/internals.js +++ b/website/client/src/libs/store/helpers/internals.js @@ -19,7 +19,7 @@ Example: tasks:todos tasks:dailys */ -export function flattenAndNamespace (namespaces) { // eslint-disable-line import/prefer-default-export +export function flattenAndNamespace (namespaces) { // eslint-disable-line import/prefer-default-export, max-len const result = {}; Object.keys(namespaces).forEach(namespace => { diff --git a/website/client/src/libs/store/helpers/public.js b/website/client/src/libs/store/helpers/public.js index d6ae5ea759..c907b7c5ca 100644 --- a/website/client/src/libs/store/helpers/public.js +++ b/website/client/src/libs/store/helpers/public.js @@ -61,7 +61,7 @@ export function mapActions (actions) { normalizeMap(actions).forEach(({ key, val }) => { res[key] = function mappedAction (...args) { - return this.$store.dispatch.apply(this.$store, [val].concat(args)); // eslint-disable-line prefer-spread + return this.$store.dispatch.apply(this.$store, [val].concat(args)); // eslint-disable-line prefer-spread, max-len }; }); diff --git a/website/client/src/libs/store/index.js b/website/client/src/libs/store/index.js index e288479108..d0af6f9ae8 100644 --- a/website/client/src/libs/store/index.js +++ b/website/client/src/libs/store/index.js @@ -9,7 +9,8 @@ export default class Store { // Store actions this._actions = actions; - // Store getters (computed properties), implemented as computed properties in the internal Vue VM + // Store getters (computed properties), + // implemented as computed properties in the internal Vue VM this.getters = {}; // Setup getters