Fix photos not showing where the response is less big than limit

This commit is contained in:
Marco Realacci 2022-12-15 15:10:06 +01:00
parent fba46f28ff
commit c0c6dccdec
2 changed files with 6 additions and 3 deletions

View file

@ -33,7 +33,7 @@ export default {
} }
if (response.data.length == 0 || response.data.length < this.limit) this.data_ended = true; if (response.data.length == 0 || response.data.length < this.limit) this.data_ended = true;
else this.stream_data = this.stream_data.concat(response.data); this.stream_data = this.stream_data.concat(response.data);
this.loading = false; this.loading = false;
}, },
loadMore() { loadMore() {

View file

@ -21,7 +21,8 @@ export default {
// this way we are sure that we fill the first page todo: check // this way we are sure that we fill the first page todo: check
// 450 is a bit more of the max height of a post // 450 is a bit more of the max height of a post
// todo: may not work in 4k screens :/ // todo: may not work in 4k screens :/
this.limit = Math.round(window.innerHeight / 450); this.limit = Math.max(Math.round(window.innerHeight / 450), 1)
this.start_idx = 0; this.start_idx = 0;
this.data_ended = false; this.data_ended = false;
this.stream_data = []; this.stream_data = [];
@ -50,9 +51,11 @@ export default {
} }
if (response.data.length == 0 || response.data.length < this.limit) this.data_ended = true; if (response.data.length == 0 || response.data.length < this.limit) this.data_ended = true;
else this.stream_data = this.stream_data.concat(response.data); this.stream_data = this.stream_data.concat(response.data);
this.loading = false; this.loading = false;
console.log(this.stream_data);
}, },
loadMore() { loadMore() {
this.start_idx += this.limit this.start_idx += this.limit