Fix: Prevent premature rendering while movies load

This commit is contained in:
Chneemann 2024-09-06 20:38:01 +02:00
parent 971d6dd48f
commit cf2eae1752
2 changed files with 10 additions and 3 deletions

View file

@ -1,5 +1,6 @@
<section> <section>
@if (movies.length > 0) { <div *ngIf="isLoading"></div>
@if (!isLoading && movies.length > 0) {
<!-- If at least one film has been uploaded --> <!-- If at least one film has been uploaded -->
@if (playMovie === "") { @if (playMovie === "") {
<app-header <app-header
@ -95,7 +96,7 @@
</div> </div>
<app-video-player [playMovie]="playMovie"></app-video-player> <app-video-player [playMovie]="playMovie"></app-video-player>
</div> </div>
} } @else { } } @if (!isLoading && movies.length === 0) {
<!-- If the database is empty --> <!-- If the database is empty -->
<app-header [browse]="true"></app-header> <app-header [browse]="true"></app-header>
<div class="error"> <div class="error">

View file

@ -30,6 +30,7 @@ export class BrowseComponent implements OnInit {
favoriteMovies: number[] = []; favoriteMovies: number[] = [];
currentMovie: any[] = []; currentMovie: any[] = [];
playMovie: string = ''; playMovie: string = '';
isLoading: boolean = true;
isWideScreen: boolean = false; isWideScreen: boolean = false;
uploadMovieOverview: boolean = false; uploadMovieOverview: boolean = false;
currentResolution: '360p' | '720p' | '1080p' = '720p'; currentResolution: '360p' | '720p' | '1080p' = '720p';
@ -104,7 +105,12 @@ export class BrowseComponent implements OnInit {
} }
async loadAllMovies() { async loadAllMovies() {
this.isLoading = true;
try {
this.movies = await this.movieService.getAllMovies(); this.movies = await this.movieService.getAllMovies();
} finally {
this.isLoading = false;
}
} }
closeVideo(): void { closeVideo(): void {