no page or limit

This commit is contained in:
Drew Ansbacher
2021-08-22 14:49:24 -06:00
committed by Matt Hill
parent 0549c86048
commit 8b862b8172
5 changed files with 64 additions and 49 deletions

View File

@@ -14,8 +14,8 @@ export class AppLogsPage {
page = 1
pkgId: string
firstTimeLoaded = false
needInfinite = false
pageLength = 20
needInfinite = true
before: string
constructor (
private readonly route: ActivatedRoute,
@@ -33,11 +33,17 @@ export class AppLogsPage {
// get logs
const logs = await this.embassyApi.getPackageLogs({
id: this.pkgId,
limit: this.pageLength,
page: this.page,
before: this.before,
})
this.firstTimeLoaded = true
if (!logs.length) {
this.needInfinite = false
return
}
this.before = logs[0].timestamp
const container = document.getElementById('container')
const beforeContainerHeight = container.scrollHeight
const newLogs = document.getElementById('template').cloneNode(true) as HTMLElement
@@ -48,9 +54,6 @@ export class AppLogsPage {
// scroll down
scrollBy(0, afterContainerHeight - beforeContainerHeight)
this.content.scrollToPoint(0, afterContainerHeight - beforeContainerHeight)
const wrapper = document.getElementById('ion-content')
this.needInfinite = logs.length === this.pageLength
} catch (e) {
this.errToast.present(e)
}
@@ -58,7 +61,6 @@ export class AppLogsPage {
async loadData (e: any): Promise<void> {
await this.getLogs()
this.page++
e.target.complete()
}
}