Fix load data pbl
This commit is contained in:
@@ -22,6 +22,7 @@ export class AlbumComponent implements OnInit {
|
|||||||
|
|
||||||
// Prevent useless data load + activate button in interface var
|
// Prevent useless data load + activate button in interface var
|
||||||
moreDataAvailable = true;
|
moreDataAvailable = true;
|
||||||
|
lockLoadData = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private elsService: ElsService,
|
private elsService: ElsService,
|
||||||
@@ -39,10 +40,16 @@ export class AlbumComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadSongs(): void {
|
loadSongs(): void {
|
||||||
|
if (this.lockLoadData) {
|
||||||
|
console.log('Loading data locked');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.moreDataAvailable) {
|
if (!this.moreDataAvailable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.lockLoadData = true;
|
||||||
this.elsService.getAlbumSongs(this.albumName, this.songs.length).subscribe(
|
this.elsService.getAlbumSongs(this.albumName, this.songs.length).subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.moreDataAvailable = data.length === ElsService.DEFAULT_SIZE;
|
this.moreDataAvailable = data.length === ElsService.DEFAULT_SIZE;
|
||||||
@@ -57,6 +64,8 @@ export class AlbumComponent implements OnInit {
|
|||||||
this.songs.push(song);
|
this.songs.push(song);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
console.log('Unlock load data');
|
||||||
|
this.lockLoadData = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user