feat(EpisodeOptions): loading icon

This commit is contained in:
2025-04-22 00:28:33 -05:00
parent 570dc00734
commit 158ac08c61
4 changed files with 45 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
import { Controller } from '@hotwired/stimulus';
/*
* The following line makes this controller "lazy": it won't be downloaded until needed
* See https://github.com/symfony/stimulus-bridge#lazy-controllers
*/
/* stimulusFetch: 'lazy' */
export default class extends Controller {
static values = {
total: Number,
count: Number,
}
static targets = ['icon']
connect() {
}
toggleIcon() {
this.iconTarget.classList.toggle('hidden');
}
increaseCount() {
this.countValue += 1;
if (this.countValue === this.totalValue) {
this.toggleIcon();
this.countValue = 0;
}
}
}

View File

@@ -16,12 +16,15 @@ export default class extends Controller {
static targets = ['list']
static outlets = ['loading-icon']
connect() {
if (true === this.activeValue) {
fetch(`/torrentio/tvshows/${this.tmdbIdValue}/${this.imdbIdValue}/${this.seasonValue}/${this.episodeValue}`)
.then(res => res.text())
.then(response => {
this.element.innerHTML = response;
this.loadingIconOutlet.increaseCount();
});
}
}