Front: add lock spinner to add entry button in search popup

This commit is contained in:
X4Lo committed 2024-10-21 15:57:30 +01:00
1 parent 1e1384d777
commit 9530b52830
2 files changed
+16 -4

No files matched your search

@@ -35,11 +35,19 @@
<p class="mb-0 text-secondary" style="font-size: 13px; margin-top: 2px;"> <p class="mb-0 text-secondary" style="font-size: 13px; margin-top: 2px;">
{{ entry.release_date | dateFormat }} {{ entry.release_date | dateFormat }}
</p> </p>
<div class="circle ms-2 me-2" *ngIf="entry.seasons"></div>
<p class="mb-0 text-secondary" style="font-size: 13px; margin-top: 2px;" *ngIf="entry.seasons">
{{ entry.seasons.length }} Seasons
</p>
</div> </div>
</div> </div>
<button class="btn btn-primary ms-auto" *ngIf="!entry.isInLibrary" <button class="btn btn-primary ms-auto" *ngIf="!entry.isInLibrary && entry.isLocked" disabled>
(click)="addToLibrary(entry.entryId.tmdb_id, entry.is_tvseries); $event.stopPropagation()"> <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
<i class="material-icons-outlined fs-5">add_circle</i> <span class="visually-hidden">Loading...</span>
</button>
<button class="btn btn-primary ms-auto justify-content-center align-items-center" *ngIf="!entry.isInLibrary && !entry.isLocked"
(click)="addToLibrary(entry); $event.stopPropagation()">
<i class="material-icons-outlined">add_circle</i>
</button> </button>
</div> </div>
</div> </div>
@@ -100,8 +100,11 @@ export class SearchPopupComponent implements OnInit, AfterViewInit {
}); });
} }
addToLibrary(tmdbId: string, isTvSerie: boolean) { addToLibrary(entry: Entry) {
this.isAddLocked = true; this.isAddLocked = true;
entry.isLocked = true;
const tmdbId = entry.entryId.tmdb_id;
const isTvSerie = entry.is_tvseries;
let obs = this.libraryService.addEntry(tmdbId, isTvSerie).subscribe({ let obs = this.libraryService.addEntry(tmdbId, isTvSerie).subscribe({
next: (entry) => { next: (entry) => {
if (entry != null) { if (entry != null) {
@@ -113,6 +116,7 @@ export class SearchPopupComponent implements OnInit, AfterViewInit {
} }
}); });
this.isAddLocked = false; this.isAddLocked = false;
entry.isLocked = false;
obs.unsubscribe(); obs.unsubscribe();
} }
}, },