mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Add "Mark as watched" video context menu item (#193)
This commit is contained in:
@@ -22,6 +22,7 @@ struct VideoContextMenuView: View {
|
||||
|
||||
@Default(.saveHistory) private var saveHistory
|
||||
|
||||
private var backgroundContext = PersistenceController.shared.container.newBackgroundContext()
|
||||
private var viewContext: NSManagedObjectContext = PersistenceController.shared.container.viewContext
|
||||
|
||||
init(video: Video) {
|
||||
@@ -46,6 +47,10 @@ struct VideoContextMenuView: View {
|
||||
continueButton
|
||||
}
|
||||
|
||||
if !(watch?.finished ?? false) {
|
||||
markAsWatchedButton
|
||||
}
|
||||
|
||||
if !watch.isNil, !watchingNow {
|
||||
removeFromHistoryButton
|
||||
}
|
||||
@@ -113,6 +118,9 @@ struct VideoContextMenuView: View {
|
||||
}
|
||||
|
||||
if let watch = watch, let watchedAtString = watch.watchedAtString {
|
||||
if watchedAtString == "in 0 seconds" {
|
||||
return "Just watched"
|
||||
}
|
||||
return "Watched \(watchedAtString)"
|
||||
}
|
||||
|
||||
@@ -127,6 +135,14 @@ struct VideoContextMenuView: View {
|
||||
}
|
||||
}
|
||||
|
||||
var markAsWatchedButton: some View {
|
||||
Button {
|
||||
Watch.markAsWatched(videoID: video.videoID, duration: video.length, context: backgroundContext)
|
||||
} label: {
|
||||
Label("Mark as watched", systemImage: "checkmark.circle.fill")
|
||||
}
|
||||
}
|
||||
|
||||
var removeFromHistoryButton: some View {
|
||||
Button {
|
||||
guard let watch = watch else {
|
||||
|
Reference in New Issue
Block a user