Don't show episode/chapter 0 in history
All checks were successful
timw4mail/HummingBirdAnimeClient/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2020-04-24 14:18:35 -04:00
parent badf941265
commit b2c86adcf5

View File

@ -73,7 +73,11 @@ abstract class HistoryTransformer {
if ($kind === 'progressed' && ! empty($entry['attributes']['changedData']['progress']))
{
$output[] = $this->transformProgress($entry);
$transformed = $this->transformProgress($entry);
if ($transformed !== NULL)
{
$output[] = $transformed;
}
}
else if ($kind === 'updated')
{
@ -170,7 +174,7 @@ abstract class HistoryTransformer {
return $output;
}
protected function transformProgress (array $entry): HistoryItem
protected function transformProgress (array $entry): ?HistoryItem
{
$id = array_keys($entry['relationships'][$this->type])[0];
$data = $entry['relationships'][$this->type][$id]['attributes'];
@ -178,6 +182,12 @@ abstract class HistoryTransformer {
$imgUrl = "images/{$this->type}/{$id}.webp";
$item = end($entry['attributes']['changedData']['progress']);
// No showing episode 0 nonsense
if (((int)$item) === 0)
{
return NULL;
}
$action = ($this->isReconsuming($entry))
? "{$this->reconsumeAction} {$item}"
: "{$this->progressAction} {$item}";