mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
* Attempt to use party data from the store rather than always fetching it from the API * Move init code to shown() to prevent unnecessary network requests * Use store party data in getGroup action if possible to save an API call * Use store data rather than API call for party in challengeModal; remove unnecessary code in guilds:getGroup action * Create party:getParty action and employ it in Group and ChallengeModal * Use store instead of action return for party data * Change how party data is stored
This commit is contained in:
committed by
Sabe Jones
parent
183c90ac3a
commit
ce14a9dadb
@@ -1,5 +1,5 @@
|
||||
<template lang="pug">
|
||||
b-modal#challenge-modal(:title="title", size='lg')
|
||||
b-modal#challenge-modal(:title="title", size='lg', @shown="shown")
|
||||
.form
|
||||
.form-group
|
||||
label
|
||||
@@ -232,24 +232,7 @@ export default {
|
||||
groups: [],
|
||||
};
|
||||
},
|
||||
async mounted () {
|
||||
this.groups = await this.$store.dispatch('guilds:getMyGuilds');
|
||||
if (this.user.party._id) {
|
||||
let party = await this.$store.dispatch('guilds:getGroup', {groupId: 'party'});
|
||||
this.groups.push({
|
||||
name: party.name,
|
||||
_id: party._id,
|
||||
privacy: 'private',
|
||||
});
|
||||
}
|
||||
|
||||
this.groups.push({
|
||||
name: this.$t('publicChallengesTitle'),
|
||||
_id: TAVERN_ID,
|
||||
});
|
||||
|
||||
this.setUpWorkingChallenge();
|
||||
},
|
||||
async mounted () {},
|
||||
watch: {
|
||||
user () {
|
||||
if (!this.challenge) this.workingChallenge.leader = this.user._id;
|
||||
@@ -315,6 +298,25 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async shown () {
|
||||
this.groups = await this.$store.dispatch('guilds:getMyGuilds');
|
||||
await this.$store.dispatch('party:getParty');
|
||||
const party = this.$store.state.party.data;
|
||||
if (party._id) {
|
||||
this.groups.push({
|
||||
name: party.name,
|
||||
_id: party._id,
|
||||
privacy: 'private',
|
||||
});
|
||||
}
|
||||
|
||||
this.groups.push({
|
||||
name: this.$t('publicChallengesTitle'),
|
||||
_id: TAVERN_ID,
|
||||
});
|
||||
|
||||
this.setUpWorkingChallenge();
|
||||
},
|
||||
setUpWorkingChallenge () {
|
||||
this.resetWorkingChallenge();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user