mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Improve history, resume videos, mark watched videos (fixes #42)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import CoreMedia
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
@@ -11,6 +12,9 @@ struct NowPlayingView: View {
|
||||
|
||||
@State private var repliesID: Comment.ID?
|
||||
|
||||
@FetchRequest(sortDescriptors: [.init(key: "watchedAt", ascending: false)])
|
||||
var watches: FetchedResults<Watch>
|
||||
|
||||
@EnvironmentObject<CommentsModel> private var comments
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
@EnvironmentObject<RecentsModel> private var recents
|
||||
@@ -94,22 +98,27 @@ struct NowPlayingView: View {
|
||||
}
|
||||
}
|
||||
|
||||
if sections.contains(.playedPreviously), saveHistory, !player.history.isEmpty {
|
||||
if sections.contains(.playedPreviously), saveHistory, !visibleWatches.isEmpty {
|
||||
Section(header: Text("Played Previously")) {
|
||||
ForEach(player.history) { item in
|
||||
ForEach(visibleWatches, id: \.videoID) { watch in
|
||||
Button {
|
||||
player.playHistory(item)
|
||||
player.playHistory(
|
||||
PlayerQueueItem.from(watch, video: player.historyVideo(watch.videoID))
|
||||
)
|
||||
player.show()
|
||||
} label: {
|
||||
VideoBanner(video: item.video, playbackTime: item.playbackTime, videoDuration: item.videoDuration)
|
||||
VideoBanner(
|
||||
video: player.historyVideo(watch.videoID),
|
||||
playbackTime: CMTime.secondsInDefaultTimescale(watch.stoppedAt),
|
||||
videoDuration: watch.videoDuration
|
||||
)
|
||||
}
|
||||
.onAppear {
|
||||
player.loadHistoryVideoDetails(watch.videoID)
|
||||
}
|
||||
.contextMenu {
|
||||
Button("Remove", role: .destructive) {
|
||||
player.removeHistory(item)
|
||||
}
|
||||
|
||||
Button("Remove All", role: .destructive) {
|
||||
player.removeHistoryItems()
|
||||
player.removeWatch(watch)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,6 +150,10 @@ struct NowPlayingView: View {
|
||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 560, maxHeight: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
private var visibleWatches: [Watch] {
|
||||
watches.filter { $0.videoID != player.currentVideo?.videoID }
|
||||
}
|
||||
|
||||
private var progressView: some View {
|
||||
VStack {
|
||||
Spacer()
|
||||
|
Reference in New Issue
Block a user