Fix Next Up Not Appearing on Home (#1142)

This commit is contained in:
Ethan Pippin 2024-07-04 22:16:56 -06:00 committed by GitHub
parent 42a895e9fa
commit 628131e008
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 6 deletions

View File

@ -22,14 +22,16 @@ extension HomeView {
private var router: HomeCoordinator.Router
@ObservedObject
var homeViewModel: HomeViewModel
var viewModel: NextUpLibraryViewModel
private var onSetPlayed: (BaseItemDto) -> Void
var body: some View {
if homeViewModel.nextUpViewModel.elements.isNotEmpty {
if viewModel.elements.isNotEmpty {
PosterHStack(
title: L10n.nextUp,
type: nextUpPosterType,
items: $homeViewModel.nextUpViewModel.elements
items: $viewModel.elements
)
.content { item in
if item.type == .episode {
@ -40,7 +42,7 @@ extension HomeView {
}
.contextMenu { item in
Button {
homeViewModel.send(.setIsPlayed(true, item))
onSetPlayed(item)
} label: {
Label(L10n.played, systemImage: "checkmark.circle")
}
@ -51,10 +53,24 @@ extension HomeView {
.trailing {
SeeAllButton()
.onSelect {
router.route(to: \.library, homeViewModel.nextUpViewModel)
router.route(to: \.library, viewModel)
}
}
}
}
}
}
extension HomeView.NextUpView {
init(viewModel: NextUpLibraryViewModel) {
self.init(
viewModel: viewModel,
onSetPlayed: { _ in }
)
}
func onSetPlayed(perform action: @escaping (BaseItemDto) -> Void) -> Self {
copy(modifying: \.onSetPlayed, with: action)
}
}

View File

@ -38,7 +38,10 @@ struct HomeView: View {
ContinueWatchingView(viewModel: viewModel)
NextUpView(homeViewModel: viewModel)
NextUpView(viewModel: viewModel.nextUpViewModel)
.onSetPlayed { item in
viewModel.send(.setIsPlayed(true, item))
}
if showRecentlyAdded {
RecentlyAddedView(viewModel: viewModel.recentlyAddedViewModel)