FIX: scroll/loading guilds (#12176)

* debounce scroll/loading guilds

* Update discovery.vue

remove threshold
This commit is contained in:
negue 2020-05-06 18:37:29 +02:00 committed by GitHub
parent be622e8b10
commit db0009ebad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;