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

@@ -6,6 +6,7 @@ struct ChannelsView: View {
@ObservedObject private var feed = FeedModel.shared
@ObservedObject private var subscriptions = SubscribedChannelsModel.shared
@ObservedObject private var accounts = AccountsModel.shared
@ObservedObject private var feedCount = UnwatchedFeedCountModel.shared
@Default(.showCacheStatus) private var showCacheStatus
@@ -25,7 +26,7 @@ struct ChannelsView: View {
}
}
.backport
.badge(channelBadge(channel))
.badge(feedCount.unwatchedByChannelText(channel))
}
.contextMenu {
if subscriptions.isSubscribing(channel.id) {
@@ -84,14 +85,6 @@ struct ChannelsView: View {
#endif
}
func channelBadge(_ channel: Channel) -> Text? {
if let count = feed.unwatchedByChannel[accounts.current]?[channel.id] {
return Text(String(count))
}
return nil
}
var header: some View {
HStack {
#if os(tvOS)