mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Unwatched videos in subscriptions
This commit is contained in:
@@ -4,6 +4,7 @@ import SwiftUI
|
||||
struct Sidebar: View {
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
@ObservedObject private var navigation = NavigationModel.shared
|
||||
@ObservedObject private var feed = FeedModel.shared
|
||||
|
||||
@Default(.showHome) private var showHome
|
||||
@Default(.visibleSections) private var visibleSections
|
||||
@@ -36,6 +37,12 @@ struct Sidebar: View {
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
}
|
||||
.onAppear {
|
||||
feed.calculateUnwatchedFeed()
|
||||
}
|
||||
.onChange(of: accounts.current) { _ in
|
||||
feed.calculateUnwatchedFeed()
|
||||
}
|
||||
.navigationTitle("Yattee")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
@@ -70,6 +77,8 @@ struct Sidebar: View {
|
||||
Label("Subscriptions", systemImage: "star.circle")
|
||||
.accessibility(label: Text("Subscriptions"))
|
||||
}
|
||||
.backport
|
||||
.badge(subscriptionsBadge)
|
||||
.id("subscriptions")
|
||||
}
|
||||
|
||||
@@ -99,6 +108,17 @@ 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