fix: links to episodes from downloads
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Search\Action\Command\GetMediaInfoCommand;
|
||||
use App\Search\Action\Handler\GetMediaInfoHandler;
|
||||
use App\Search\TvEpisodePaginator;
|
||||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
|
||||
use Symfony\UX\LiveComponent\Attribute\LiveAction;
|
||||
use Symfony\UX\LiveComponent\Attribute\LiveArg;
|
||||
use Symfony\UX\LiveComponent\Attribute\LiveProp;
|
||||
use Symfony\UX\LiveComponent\DefaultActionTrait;
|
||||
|
||||
@@ -27,6 +29,12 @@ final class TvEpisodeList
|
||||
#[LiveProp(writable: true)]
|
||||
public int $season = 1;
|
||||
|
||||
#[LiveProp(writable: true)]
|
||||
public int $reloadCount = 0;
|
||||
|
||||
#[LiveProp(writable: true)]
|
||||
public ?int $episodeNumber = null;
|
||||
|
||||
public function __construct(
|
||||
private GetMediaInfoHandler $getMediaInfoHandler,
|
||||
) {}
|
||||
@@ -34,6 +42,14 @@ final class TvEpisodeList
|
||||
public function getEpisodes()
|
||||
{
|
||||
$results = $this->getMediaInfoHandler->handle(new GetMediaInfoCommand($this->imdbId, "tvshows", $this->season));
|
||||
|
||||
if (null !== $this->episodeNumber) {
|
||||
$this->pageNumber = ceil($this->episodeNumber / $this->perPage);
|
||||
$this->episodeNumber = null;
|
||||
}
|
||||
|
||||
$this->reloadCount++;
|
||||
|
||||
return new TvEpisodePaginator()->paginate($results, $this->pageNumber, $this->perPage);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user