Skip to content

Commit

Permalink
fix(sonarr): correctly support Sonarr v4 season posters
Browse files Browse the repository at this point in the history
  • Loading branch information
JagandeepBrar committed Aug 30, 2023
1 parent ea0fe19 commit 08228ef
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:collection/collection.dart' show IterableExtension;
import 'package:flutter/material.dart';
import 'package:collection/collection.dart' show IterableExtension;
import 'package:lunasea/core.dart';
import 'package:lunasea/extensions/datetime.dart';
import 'package:lunasea/extensions/int/bytes.dart';
Expand Down Expand Up @@ -28,10 +28,7 @@ class _State extends State<SonarrSeriesDetailsSeasonTile> {
Widget build(BuildContext context) {
return LunaBlock(
posterPlaceholderIcon: LunaIcons.VIDEO_CAM,
posterUrl: widget.season.images
?.firstWhereOrNull((e) => e.coverType == 'poster')
?.url ??
'',
posterUrl: _posterUrl(),
posterHeaders: context.read<SonarrState>().headers,
title: widget.season.lunaTitle,
disabled: !widget.season.monitored!,
Expand All @@ -46,6 +43,12 @@ class _State extends State<SonarrSeriesDetailsSeasonTile> {
);
}

String _posterUrl() {
final images = widget.season.images;
final poster = images?.firstWhereOrNull((e) => e.coverType == 'poster');
return poster?.remoteUrl ?? poster?.url ?? '';
}

Future<void> _onTap() async {
SonarrRoutes.SERIES_SEASON.go(params: {
'series': (widget.seriesId ?? -1).toString(),
Expand Down

0 comments on commit 08228ef

Please sign in to comment.