Feed count model

This commit is contained in:
Arkadiusz Fal
2022-12-16 22:26:14 +01:00
parent 4acf9284f4
commit 26d3fba0f3
7 changed files with 60 additions and 56 deletions

View File

@@ -4,8 +4,8 @@ import SwiftUI
struct AppSidebarSubscriptions: View {
@ObservedObject private var navigation = NavigationModel.shared
@ObservedObject private var feed = FeedModel.shared
@ObservedObject private var feedCount = UnwatchedFeedCountModel.shared
@ObservedObject private var subscriptions = SubscribedChannelsModel.shared
@ObservedObject private var accounts = AccountsModel.shared
var body: some View {
@@ -23,9 +23,9 @@ struct AppSidebarSubscriptions: View {
} else {
Label(channel.name, systemImage: RecentsModel.symbolSystemImage(channel.name))
}
feedCount.unwatchedByChannelText(channel)
}
.backport
.badge(channelBadge(channel))
}
.contextMenu {
if subscriptions.isSubscribing(channel.id) {
@@ -41,14 +41,6 @@ struct AppSidebarSubscriptions: View {
}
}
func channelBadge(_ channel: Channel) -> Text? {
if let count = feed.unwatchedByChannel[accounts.current]?[channel.id] {
return Text(String(count))
}
return nil
}
@ViewBuilder func toggleWatchedButton(_ channel: Channel) -> some View {
if feed.canMarkChannelAsWatched(channel.id) {
markChannelAsWatchedButton(channel)