Add action to mark channel feed as watched/unwatched

This commit is contained in:
Arkadiusz Fal
2022-12-14 18:10:01 +01:00
parent b55c6f8619
commit a156ef6a3f
5 changed files with 196 additions and 16 deletions

View File

@@ -79,6 +79,10 @@ struct Sidebar: View {
}
.backport
.badge(subscriptionsBadge)
.contextMenu {
playUnwatchedButton
toggleWatchedButton
}
.id("subscriptions")
}
@@ -108,6 +112,40 @@ struct Sidebar: View {
}
}
var playUnwatchedButton: some View {
Button {
feed.playUnwatchedFeed()
} label: {
Label("Play all unwatched", systemImage: "play")
}
.disabled(!feed.canPlayUnwatchedFeed)
}
@ViewBuilder var toggleWatchedButton: some View {
if feed.canMarkAllFeedAsWatched {
markAllFeedAsWatchedButton
} else {
markAllFeedAsUnwatchedButton
}
}
var markAllFeedAsWatchedButton: some View {
Button {
feed.markAllFeedAsWatched()
} label: {
Label("Mark all as watched", systemImage: "checkmark.circle.fill")
}
.disabled(!feed.canMarkAllFeedAsWatched)
}
var markAllFeedAsUnwatchedButton: some View {
Button {
feed.markAllFeedAsUnwatched()
} label: {
Label("Mark all as unwatched", systemImage: "checkmark.circle")
}
}
private var subscriptionsBadge: Text? {
guard let account = accounts.current,
let unwatched = feed.unwatched[account],