Load more on scroll

This commit is contained in:
Jiiks 2018-11-26 17:15:26 +02:00
parent d5a82ab2b3
commit 98bf4d21ac
2 changed files with 14 additions and 5 deletions

View File

@ -42,7 +42,7 @@ async function dummyThemes() {
const dummies = [];
for (let i = 0; i < 10; i++) {
dummies.push({
id: `theme${i}`,
id: `theme${i}${btoa(Math.random()).substring(3, 9)}`,
name: `Dummy ${i}`,
tags: dummyTags,
installs: Math.floor(Math.random() * 10000),

View File

@ -84,7 +84,7 @@
await this.ThemeManager.refreshThemes();
},
async refreshOnline() {
if (this.loadingOnline) return;
if (this.loadingOnline || this.loadingMore) return;
this.loadingOnline = true;
try {
const getThemes = await BdWebApi.themes.get();
@ -123,11 +123,20 @@
});
},
searchInput(e) {
if (this.loadingOnline) return;
if (this.loadingOnline || this.loadingMore) return;
this.refreshOnline();
},
scrollend(e) {
console.log('scrollend');
async scrollend(e) {
if (this.loadingOnline || this.loadingMore) return;
this.loadingMore = true;
try {
const getThemes = await BdWebApi.themes.get();
this.onlineThemes.docs = [...this.onlineThemes.docs, ...getThemes.docs];
} catch (err) {
Logger.err('ThemesView', err);
} finally {
this.loadingMore = false;
}
}
}
}