fix: passes latest season to add monitor call
This commit is contained in:
@@ -13,34 +13,7 @@ export default class extends Controller {
|
|||||||
tmdbId: String,
|
tmdbId: String,
|
||||||
imdbId: String,
|
imdbId: String,
|
||||||
title: String,
|
title: String,
|
||||||
}
|
season: Number,
|
||||||
|
|
||||||
initialize() {
|
|
||||||
// Called once when the controller is first instantiated (per element)
|
|
||||||
|
|
||||||
// Here you can initialize variables, create scoped callables for event
|
|
||||||
// listeners, instantiate external libraries, etc.
|
|
||||||
// this._fooBar = this.fooBar.bind(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
connect() {
|
|
||||||
// Called every time the controller is connected to the DOM
|
|
||||||
// (on page load, when it's added to the DOM, moved in the DOM, etc.)
|
|
||||||
|
|
||||||
// Here you can add event listeners on the element or target elements,
|
|
||||||
// add or remove classes, attributes, dispatch custom events, etc.
|
|
||||||
// this.fooTarget.addEventListener('click', this._fooBar)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add custom controller actions here
|
|
||||||
// fooBar() { this.fooTarget.classList.toggle(this.bazClass) }
|
|
||||||
|
|
||||||
disconnect() {
|
|
||||||
// Called anytime its element is disconnected from the DOM
|
|
||||||
// (on page change, when it's removed from or moved in the DOM, etc.)
|
|
||||||
|
|
||||||
// Here you should remove all event listeners added in "connect()"
|
|
||||||
// this.fooTarget.removeEventListener('click', this._fooBar)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
@@ -53,34 +26,13 @@ export default class extends Controller {
|
|||||||
imdbId: this.imdbIdValue,
|
imdbId: this.imdbIdValue,
|
||||||
title: this.titleValue,
|
title: this.titleValue,
|
||||||
monitorType: 'tvshows',
|
monitorType: 'tvshows',
|
||||||
|
season: this.seasonValue
|
||||||
});
|
});
|
||||||
if (this.hasDialogOutlet) {
|
if (this.hasDialogOutlet) {
|
||||||
this.dialogOutlet.close();
|
this.dialogOutlet.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async monitorSeason() {
|
|
||||||
await this.makeMonitor({
|
|
||||||
tmdbId: this.tmdbIdValue,
|
|
||||||
imdbId: this.imdbIdValue,
|
|
||||||
title: this.titleValue,
|
|
||||||
monitorType: 'tvseason',
|
|
||||||
season: this.resultFilterOutlet.activeFilter['season'],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async monitorEpisode() {
|
|
||||||
// ToDo: figure out how to set episode
|
|
||||||
await this.makeMonitor({
|
|
||||||
tmdbId: this.tmdbIdValue,
|
|
||||||
imdbId: this.imdbIdValue,
|
|
||||||
title: this.titleValue,
|
|
||||||
monitorType: 'tvepisode',
|
|
||||||
season: this.resultFilterOutlet.activeFilter['season'],
|
|
||||||
episode: '',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async makeMonitor(body) {
|
async makeMonitor(body) {
|
||||||
const response = await fetch('/api/monitor', {
|
const response = await fetch('/api/monitor', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -90,7 +42,6 @@ export default class extends Controller {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify(body)
|
body: JSON.stringify(body)
|
||||||
});
|
});
|
||||||
|
|
||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ class TmdbTvShowResultDenormalizer extends TmdbResultDenormalizer implements Den
|
|||||||
$result->year = (null !== $airDate) ? $airDate->format('Y') : null;
|
$result->year = (null !== $airDate) ? $airDate->format('Y') : null;
|
||||||
$result->mediaType = MediaType::TvShow->value;
|
$result->mediaType = MediaType::TvShow->value;
|
||||||
|
|
||||||
|
if (is_array($result->episodes)) {
|
||||||
|
$result->latestSeason = array_key_last($result->episodes);
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,5 +56,6 @@ class TmdbResult
|
|||||||
public ?array $producers = null,
|
public ?array $producers = null,
|
||||||
public ?int $runtime = null,
|
public ?int $runtime = null,
|
||||||
public ?int $numberSeasons = null,
|
public ?int $numberSeasons = null,
|
||||||
|
public ?int $latestSeason = null,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
tmdbId: results.media.tmdbId,
|
tmdbId: results.media.tmdbId,
|
||||||
imdbId: results.media.imdbId,
|
imdbId: results.media.imdbId,
|
||||||
title: results.media.title,
|
title: results.media.title,
|
||||||
|
season: results.media.latestSeason,
|
||||||
})}}
|
})}}
|
||||||
data-monitor-button-result-filter-outlet="#filter"
|
data-monitor-button-result-filter-outlet="#filter"
|
||||||
data-monitor-button-dialog-outlet=".monitor-modal"
|
data-monitor-button-dialog-outlet=".monitor-modal"
|
||||||
|
|||||||
Reference in New Issue
Block a user