mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-07 10:14:13 -04:00
Update page.ts
This commit is contained in:
parent
50cd5f55ed
commit
3338be9e24
@ -2,11 +2,12 @@ import {HttpClient} from "@angular/common/http";
|
|||||||
|
|
||||||
export class Page<T>
|
export class Page<T>
|
||||||
{
|
{
|
||||||
this: string
|
this: string;
|
||||||
next: string
|
next: string;
|
||||||
first: string
|
first: string;
|
||||||
count: number
|
count: number;
|
||||||
items: T[]
|
items: T[];
|
||||||
|
private _isLoading: boolean = false;
|
||||||
|
|
||||||
constructor(init?:Partial<Page<T>>)
|
constructor(init?:Partial<Page<T>>)
|
||||||
{
|
{
|
||||||
@ -15,17 +16,20 @@ export class Page<T>
|
|||||||
|
|
||||||
loadNext(client: HttpClient)
|
loadNext(client: HttpClient)
|
||||||
{
|
{
|
||||||
if (this.next == null)
|
if (this.next == null || this._isLoading)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this._isLoading = true;
|
||||||
client.get<Page<T>>(this.next).subscribe(x =>
|
client.get<Page<T>>(this.next).subscribe(x =>
|
||||||
{
|
{
|
||||||
this.items.push(...x.items);
|
this.items.push(...x.items);
|
||||||
this.count += x.count;
|
this.count += x.count;
|
||||||
this.next = x.next;
|
this.next = x.next;
|
||||||
this.this = x.this;
|
this.this = x.this;
|
||||||
|
this._isLoading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
changeType(type: string)
|
changeType(type: string)
|
||||||
{
|
{
|
||||||
return this.first.replace(/\/\w*($|\?)/, `/${type}$1`)
|
return this.first.replace(/\/\w*($|\?)/, `/${type}$1`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user