FIX: scroll/loading guilds (#12176)
* debounce scroll/loading guilds * Update discovery.vue remove threshold
This commit is contained in:
@@ -52,7 +52,7 @@ b-dropdown(:text="$t('sort')", right=true)
|
||||
/>
|
||||
<mugen-scroll
|
||||
v-show="loading"
|
||||
:handler="fetchGuilds"
|
||||
:handler="triggerFetchGuilds"
|
||||
:should-handle="!loading && !hasLoadedAllGuilds"
|
||||
:handle-on-mount="true"
|
||||
>
|
||||
@@ -90,6 +90,7 @@ b-dropdown(:text="$t('sort')", right=true)
|
||||
|
||||
<script>
|
||||
import MugenScroll from 'vue-mugen-scroll';
|
||||
import debounce from 'lodash/debounce';
|
||||
import PublicGuildItem from './publicGuildItem';
|
||||
import Sidebar from './sidebar';
|
||||
import groupUtilities from '@/mixins/groupsUtilities';
|
||||
@@ -217,13 +218,19 @@ export default {
|
||||
_mapCategories(guilds);
|
||||
this.guilds = guilds;
|
||||
},
|
||||
triggerFetchGuilds () {
|
||||
this.loading = true;
|
||||
this.debounceFetchGuilds();
|
||||
},
|
||||
debounceFetchGuilds: debounce(function debounceFetchGuilds () {
|
||||
this.fetchGuilds();
|
||||
}, 1000),
|
||||
async fetchGuilds () {
|
||||
// We have the data cached
|
||||
if (this.lastPageLoaded === 0 && this.guilds.length > 0) {
|
||||
this.lastPageLoaded += 1;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
this.queryFilters.page = this.lastPageLoaded;
|
||||
const guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters);
|
||||
if (guilds.length === 0) this.hasLoadedAllGuilds = true;
|
||||
|
||||
Reference in New Issue
Block a user