Load more on scroll
This commit is contained in:
parent
d5a82ab2b3
commit
98bf4d21ac
|
@ -42,7 +42,7 @@ async function dummyThemes() {
|
||||||
const dummies = [];
|
const dummies = [];
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
dummies.push({
|
dummies.push({
|
||||||
id: `theme${i}`,
|
id: `theme${i}${btoa(Math.random()).substring(3, 9)}`,
|
||||||
name: `Dummy ${i}`,
|
name: `Dummy ${i}`,
|
||||||
tags: dummyTags,
|
tags: dummyTags,
|
||||||
installs: Math.floor(Math.random() * 10000),
|
installs: Math.floor(Math.random() * 10000),
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
await this.ThemeManager.refreshThemes();
|
await this.ThemeManager.refreshThemes();
|
||||||
},
|
},
|
||||||
async refreshOnline() {
|
async refreshOnline() {
|
||||||
if (this.loadingOnline) return;
|
if (this.loadingOnline || this.loadingMore) return;
|
||||||
this.loadingOnline = true;
|
this.loadingOnline = true;
|
||||||
try {
|
try {
|
||||||
const getThemes = await BdWebApi.themes.get();
|
const getThemes = await BdWebApi.themes.get();
|
||||||
|
@ -123,11 +123,20 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
searchInput(e) {
|
searchInput(e) {
|
||||||
if (this.loadingOnline) return;
|
if (this.loadingOnline || this.loadingMore) return;
|
||||||
this.refreshOnline();
|
this.refreshOnline();
|
||||||
},
|
},
|
||||||
scrollend(e) {
|
async scrollend(e) {
|
||||||
console.log('scrollend');
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue