mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-04 04:59:40 +00:00
FIX: scroll/loading guilds (#12176)
* debounce scroll/loading guilds * Update discovery.vue remove threshold
This commit is contained in:
parent
be622e8b10
commit
db0009ebad
1 changed files with 9 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue