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
|
||||
moreDataAvailable = true;
|
||||
lockLoadData = false;
|
||||
|
||||
constructor(
|
||||
private elsService: ElsService,
|
||||
@@ -39,10 +40,16 @@ export class AlbumComponent implements OnInit {
|
||||
}
|
||||
|
||||
loadSongs(): void {
|
||||
if (this.lockLoadData) {
|
||||
console.log('Loading data locked');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.moreDataAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.lockLoadData = true;
|
||||
this.elsService.getAlbumSongs(this.albumName, this.songs.length).subscribe(
|
||||
data => {
|
||||
this.moreDataAvailable = data.length === ElsService.DEFAULT_SIZE;
|
||||
@@ -57,6 +64,8 @@ export class AlbumComponent implements OnInit {
|
||||
this.songs.push(song);
|
||||
});
|
||||
}
|
||||
console.log('Unlock load data');
|
||||
this.lockLoadData = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user