fix(livetv): show guide without favorites
This commit is contained in:
@@ -31,6 +31,21 @@ String favoriteChannelKey(String source, String id) => '$source\u0000$id';
|
||||
String liveTvChannelScopeKey(LiveTvChannel channel) =>
|
||||
'${channel.serverId ?? ''}\u0000${channel.liveDvrKey ?? ''}\u0000${channel.key}';
|
||||
|
||||
List<LiveTvChannel> filterLiveTvChannelsForFavorites({
|
||||
required List<LiveTvChannel> channels,
|
||||
required bool favoritesOnly,
|
||||
required Iterable<FavoriteChannel> favorites,
|
||||
required String Function(LiveTvChannel channel) sourceForChannel,
|
||||
}) {
|
||||
if (!favoritesOnly || favorites.isEmpty) return channels;
|
||||
|
||||
final channelMap = {
|
||||
for (final channel in channels) favoriteChannelKey(sourceForChannel(channel), channel.key): channel,
|
||||
};
|
||||
|
||||
return [for (final favorite in favorites) ?channelMap[favorite.stableKey]];
|
||||
}
|
||||
|
||||
@JsonSerializable(createToJson: false)
|
||||
class LiveTvChannel with MultiServerFields {
|
||||
@JsonKey(readValue: _readChannelKey)
|
||||
|
||||
@@ -71,15 +71,12 @@ class _LiveTvScreenState extends State<LiveTvScreen>
|
||||
final Map<String, String> _favoriteStoreBySource = {};
|
||||
final Map<String, FavoriteChannelPersistenceMode> _favoriteModeByStore = {};
|
||||
|
||||
List<LiveTvChannel> get _filteredChannels {
|
||||
if (!_showFavoritesOnly) return _channels;
|
||||
if (_favoriteKeys.isEmpty) return const [];
|
||||
final channelMap = {for (final c in _channels) _favoriteKeyForChannel(c): c};
|
||||
return [
|
||||
for (final fav in _favoriteChannels)
|
||||
if (channelMap.containsKey(fav.stableKey)) channelMap[fav.stableKey]!,
|
||||
];
|
||||
}
|
||||
List<LiveTvChannel> get _filteredChannels => filterLiveTvChannelsForFavorites(
|
||||
channels: _channels,
|
||||
favoritesOnly: _showFavoritesOnly,
|
||||
favorites: _favoriteChannels,
|
||||
sourceForChannel: _sourceForChannel,
|
||||
);
|
||||
|
||||
String _liveServerScopeKey(LiveTvServerInfo serverInfo) => '${serverInfo.serverId}\u0000${serverInfo.dvrKey}';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user