mirror of
https://github.com/yattee/yattee.git
synced 2025-08-04 01:34:10 +00:00
Add action to mark channel feed as watched/unwatched
This commit is contained in:
@@ -23,6 +23,7 @@ struct ChannelVideosView: View {
|
||||
#endif
|
||||
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
@ObservedObject private var feed = FeedModel.shared
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
@ObservedObject private var recents = RecentsModel.shared
|
||||
@ObservedObject private var subscriptions = SubscribedChannelsModel.shared
|
||||
@@ -129,6 +130,10 @@ struct ChannelVideosView: View {
|
||||
FavoriteButton(item: FavoriteItem(section: .channel(accounts.app.appType.rawValue, presentedChannel.id, presentedChannel.name)))
|
||||
}
|
||||
}
|
||||
|
||||
ToolbarItem {
|
||||
toggleWatchedButton
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -231,6 +236,10 @@ struct ChannelVideosView: View {
|
||||
FavoriteButton(item: FavoriteItem(section: .channel(accounts.app.appType.rawValue, channel.id, channel.name)))
|
||||
}
|
||||
|
||||
if subscriptions.isSubscribing(channel.id) {
|
||||
toggleWatchedButton
|
||||
}
|
||||
|
||||
ListingStyleButtons(listingStyle: $channelPlaylistListingStyle)
|
||||
}
|
||||
} label: {
|
||||
@@ -341,6 +350,35 @@ struct ChannelVideosView: View {
|
||||
private var navigationTitle: String {
|
||||
presentedChannel?.name ?? "No channel"
|
||||
}
|
||||
|
||||
@ViewBuilder var toggleWatchedButton: some View {
|
||||
if let channel = presentedChannel {
|
||||
if feed.canMarkChannelAsWatched(channel.id) {
|
||||
markChannelAsWatchedButton
|
||||
} else {
|
||||
markChannelAsUnwatchedButton
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var markChannelAsWatchedButton: some View {
|
||||
Button {
|
||||
guard let channel = presentedChannel else { return }
|
||||
feed.markChannelAsWatched(channel.id)
|
||||
} label: {
|
||||
Label("Mark channel feed as watched", systemImage: "checkmark.circle.fill")
|
||||
}
|
||||
.disabled(!feed.canMarkAllFeedAsWatched)
|
||||
}
|
||||
|
||||
var markChannelAsUnwatchedButton: some View {
|
||||
Button {
|
||||
guard let channel = presentedChannel else { return }
|
||||
feed.markChannelAsUnwatched(channel.id)
|
||||
} label: {
|
||||
Label("Mark channel feed as unwatched", systemImage: "checkmark.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ChannelVideosView_Previews: PreviewProvider {
|
||||
|
@@ -28,6 +28,10 @@ struct AppSidebarSubscriptions: View {
|
||||
.badge(channelBadge(channel))
|
||||
}
|
||||
.contextMenu {
|
||||
if subscriptions.isSubscribing(channel.id) {
|
||||
toggleWatchedButton(channel)
|
||||
}
|
||||
|
||||
Button("Unsubscribe") {
|
||||
navigation.presentUnsubscribeAlert(channel, subscriptions: subscriptions)
|
||||
}
|
||||
@@ -44,6 +48,31 @@ struct AppSidebarSubscriptions: View {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ViewBuilder func toggleWatchedButton(_ channel: Channel) -> some View {
|
||||
if feed.canMarkChannelAsWatched(channel.id) {
|
||||
markChannelAsWatchedButton(channel)
|
||||
} else {
|
||||
markChannelAsUnwatchedButton(channel)
|
||||
}
|
||||
}
|
||||
|
||||
func markChannelAsWatchedButton(_ channel: Channel) -> some View {
|
||||
Button {
|
||||
feed.markChannelAsWatched(channel.id)
|
||||
} label: {
|
||||
Label("Mark channel feed as watched", systemImage: "checkmark.circle.fill")
|
||||
}
|
||||
.disabled(!feed.canMarkAllFeedAsWatched)
|
||||
}
|
||||
|
||||
func markChannelAsUnwatchedButton(_ channel: Channel) -> some View {
|
||||
Button {
|
||||
feed.markChannelAsUnwatched(channel.id)
|
||||
} label: {
|
||||
Label("Mark channel feed as unwatched", systemImage: "checkmark.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AppSidebarSubscriptions_Previews: PreviewProvider {
|
||||
|
@@ -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],
|
||||
|
@@ -28,6 +28,9 @@ struct ChannelsView: View {
|
||||
.badge(channelBadge(channel))
|
||||
}
|
||||
.contextMenu {
|
||||
if subscriptions.isSubscribing(channel.id) {
|
||||
toggleWatchedButton(channel)
|
||||
}
|
||||
Button {
|
||||
subscriptions.unsubscribe(channel.id)
|
||||
} label: {
|
||||
@@ -124,6 +127,31 @@ struct ChannelsView: View {
|
||||
.padding(.top, 15)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder func toggleWatchedButton(_ channel: Channel) -> some View {
|
||||
if feed.canMarkChannelAsWatched(channel.id) {
|
||||
markChannelAsWatchedButton(channel)
|
||||
} else {
|
||||
markChannelAsUnwatchedButton(channel)
|
||||
}
|
||||
}
|
||||
|
||||
func markChannelAsWatchedButton(_ channel: Channel) -> some View {
|
||||
Button {
|
||||
feed.markChannelAsWatched(channel.id)
|
||||
} label: {
|
||||
Label("Mark channel feed as watched", systemImage: "checkmark.circle.fill")
|
||||
}
|
||||
.disabled(!feed.canMarkAllFeedAsWatched)
|
||||
}
|
||||
|
||||
func markChannelAsUnwatchedButton(_ channel: Channel) -> some View {
|
||||
Button {
|
||||
feed.markChannelAsUnwatched(channel.id)
|
||||
} label: {
|
||||
Label("Mark channel feed as unwatched", systemImage: "checkmark.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ChannelsView_Previews: PreviewProvider {
|
||||
|
Reference in New Issue
Block a user