mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Feed count model
This commit is contained in:
@@ -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)
|
||||
|
@@ -7,6 +7,7 @@ struct AppTabNavigation: View {
|
||||
private var player = PlayerModel.shared
|
||||
@ObservedObject private var feed = FeedModel.shared
|
||||
@ObservedObject private var subscriptions = SubscribedChannelsModel.shared
|
||||
@ObservedObject private var feedCount = UnwatchedFeedCountModel.shared
|
||||
|
||||
@Default(.showHome) private var showHome
|
||||
@Default(.showDocuments) private var showDocuments
|
||||
@@ -94,18 +95,7 @@ struct AppTabNavigation: View {
|
||||
}
|
||||
.tag(TabSelection.subscriptions)
|
||||
.backport
|
||||
.badge(subscriptionsBadge)
|
||||
}
|
||||
|
||||
var subscriptionsBadge: Text? {
|
||||
guard let account = accounts.current,
|
||||
let unwatched = feed.unwatched[account],
|
||||
unwatched > 0
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return Text("\(String(unwatched))")
|
||||
.badge(feedCount.unwatchedText)
|
||||
}
|
||||
|
||||
private var subscriptionsVisible: Bool {
|
||||
|
@@ -5,6 +5,7 @@ struct Sidebar: View {
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
@ObservedObject private var feed = FeedModel.shared
|
||||
@ObservedObject private var feedCount = UnwatchedFeedCountModel.shared
|
||||
|
||||
@Default(.showHome) private var showHome
|
||||
@Default(.visibleSections) private var visibleSections
|
||||
@@ -78,7 +79,7 @@ struct Sidebar: View {
|
||||
.accessibility(label: Text("Subscriptions"))
|
||||
}
|
||||
.backport
|
||||
.badge(subscriptionsBadge)
|
||||
.badge(feedCount.unwatchedText)
|
||||
.contextMenu {
|
||||
playUnwatchedButton
|
||||
toggleWatchedButton
|
||||
@@ -146,17 +147,6 @@ struct Sidebar: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var subscriptionsBadge: Text? {
|
||||
guard let account = accounts.current,
|
||||
let unwatched = feed.unwatched[account],
|
||||
unwatched > 0
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return Text("\(String(unwatched))")
|
||||
}
|
||||
|
||||
private func scrollScrollViewToItem(scrollView: ScrollViewProxy, for selection: TabSelection) {
|
||||
if case .recentlyOpened = selection {
|
||||
scrollView.scrollTo("recentlyOpened")
|
||||
|
Reference in New Issue
Block a user