mirror of
https://github.com/HabitRPG/habitica.git
synced 2026-05-03 11:31:13 -05:00
Fix guilds fetching (#9416)
* fix guilds fetching * fix missing categories
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
mugen-scroll(
|
||||
:handler="fetchGuilds",
|
||||
:should-handle="!loading && !this.hasLoadedAllGuilds",
|
||||
:handle-on-mount="false",
|
||||
:handle-on-mount="true",
|
||||
v-show="loading",
|
||||
)
|
||||
span(v-once) {{ $t('loading') }}
|
||||
@@ -53,6 +53,16 @@ import bDropdownItem from 'bootstrap-vue/lib/components/dropdown-item';
|
||||
|
||||
import positiveIcon from 'assets/svg/positive.svg';
|
||||
|
||||
function _mapCategories (guilds) {
|
||||
guilds.forEach((guild) => {
|
||||
if (!guild.categories) return;
|
||||
guild.categorySlugs = guild.categories.map(cat => {
|
||||
if (!cat) return;
|
||||
return cat.slug;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
mixins: [groupUtilities],
|
||||
components: { PublicGuildItem, MugenScroll, Sidebar, bFormSelect, bDropdown, bDropdownItem },
|
||||
@@ -91,9 +101,6 @@ export default {
|
||||
},
|
||||
};
|
||||
},
|
||||
created () {
|
||||
if (!this.$store.state.publicGuilds) this.fetchGuilds();
|
||||
},
|
||||
computed: {
|
||||
filteredGuilds () {
|
||||
let search = this.search;
|
||||
@@ -117,12 +124,7 @@ export default {
|
||||
this.queryFilters.search = eventData.searchTerm;
|
||||
|
||||
let guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters);
|
||||
guilds.forEach((guild) => {
|
||||
if (!guild.categories) return;
|
||||
guild.categorySlugs = guild.categories.map(cat => {
|
||||
return cat.slug;
|
||||
});
|
||||
});
|
||||
_mapCategories(guilds);
|
||||
this.guilds = guilds;
|
||||
},
|
||||
async updateFilters (eventData) {
|
||||
@@ -170,11 +172,7 @@ export default {
|
||||
}
|
||||
|
||||
let guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters);
|
||||
guilds.forEach((guild) => {
|
||||
guild.categorySlugs = guild.categories.map(cat => {
|
||||
return cat.slug;
|
||||
});
|
||||
});
|
||||
_mapCategories(guilds);
|
||||
this.guilds = guilds;
|
||||
},
|
||||
async fetchGuilds () {
|
||||
@@ -187,11 +185,7 @@ export default {
|
||||
let guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters);
|
||||
if (guilds.length === 0) this.hasLoadedAllGuilds = true;
|
||||
|
||||
guilds.forEach((guild) => {
|
||||
guild.categorySlugs = guild.categories.map(cat => {
|
||||
return cat.slug;
|
||||
});
|
||||
});
|
||||
_mapCategories(guilds);
|
||||
this.guilds.push(...guilds);
|
||||
|
||||
this.lastPageLoaded++;
|
||||
|
||||
@@ -89,11 +89,6 @@ export async function create (store, payload) {
|
||||
let response = await axios.post('/api/v3/groups/', payload.group);
|
||||
let newGroup = response.data.data;
|
||||
|
||||
// @TODO: Add party
|
||||
if (newGroup.privacy === 'public') {
|
||||
store.state.publicGuilds.push(newGroup);
|
||||
}
|
||||
|
||||
if (newGroup.leader._id === store.state.user.data._id || newGroup.privacy === 'private') {
|
||||
store.state.myGuilds.push(newGroup);
|
||||
}
|
||||
@@ -112,9 +107,6 @@ export async function update (store, payload) {
|
||||
|
||||
let updatedGroup = response.data.data;
|
||||
|
||||
// @TODO: Replace old group
|
||||
// store.state.publicGuilds.push(newGroup);
|
||||
|
||||
return updatedGroup;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,6 @@ export default function () {
|
||||
'time-travelers': asyncResourceFactory(),
|
||||
},
|
||||
myGuilds: [],
|
||||
publicGuilds: [],
|
||||
groupFormOptions: {
|
||||
creatingParty: false,
|
||||
groupId: '',
|
||||
|
||||
Reference in New Issue
Block a user