1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 22:00:31 +05:30

Add browsing setting for unwatched feed

Fix #383
This commit is contained in:
Arkadiusz Fal 2023-02-28 21:17:12 +01:00
parent b9ad5bc633
commit f8d79bb08c
8 changed files with 19 additions and 6 deletions

View File

@ -115,7 +115,7 @@ final class FeedModel: ObservableObject, CacheModel {
}
func calculateUnwatchedFeed() {
guard let account = accounts.current, accounts.signedIn else { return }
guard let account = accounts.current, accounts.signedIn, Defaults[.showUnwatchedFeedBadges] else { return }
let feed = cacheModel.retrieveFeed(account: account)
backgroundContext.perform { [weak self] in
guard let self else { return }

View File

@ -51,6 +51,7 @@ extension Defaults.Keys {
#if os(iOS)
static let lockPortraitWhenBrowsing = Key<Bool>("lockPortraitWhenBrowsing", default: UIDevice.current.userInterfaceIdiom == .phone)
#endif
static let showUnwatchedFeedBadges = Key<Bool>("showUnwatchedFeedBadges", default: false)
static let expandChannelDescription = Key<Bool>("expandChannelDescription", default: false)
static let channelOnThumbnail = Key<Bool>("channelOnThumbnail", default: false)
static let timeOnThumbnail = Key<Bool>("timeOnThumbnail", default: true)

View File

@ -8,6 +8,8 @@ struct AppSidebarSubscriptions: View {
@ObservedObject private var subscriptions = SubscribedChannelsModel.shared
@ObservedObject private var accounts = AccountsModel.shared
@Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges
var body: some View {
Section(header: Text("Subscriptions")) {
ForEach(subscriptions.all) { channel in
@ -26,7 +28,7 @@ struct AppSidebarSubscriptions: View {
Spacer()
}
.backport
.badge(feedCount.unwatchedByChannelText(channel))
.badge(showUnwatchedFeedBadges ? feedCount.unwatchedByChannelText(channel) : nil)
}
.contextMenu {
if subscriptions.isSubscribing(channel.id) {

View File

@ -13,6 +13,7 @@ struct AppTabNavigation: View {
@Default(.showDocuments) private var showDocuments
@Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem
@Default(.visibleSections) private var visibleSections
@Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges
let persistenceController = PersistenceController.shared
@ -95,7 +96,7 @@ struct AppTabNavigation: View {
}
.tag(TabSelection.subscriptions)
.backport
.badge(feedCount.unwatchedText)
.badge(showUnwatchedFeedBadges ? feedCount.unwatchedText : nil)
}
private var subscriptionsVisible: Bool {

View File

@ -12,6 +12,7 @@ struct Sidebar: View {
#if os(iOS)
@Default(.showDocuments) private var showDocuments
#endif
@Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges
var body: some View {
ScrollViewReader { scrollView in
@ -79,7 +80,7 @@ struct Sidebar: View {
.accessibility(label: Text("Subscriptions"))
}
.backport
.badge(feedCount.unwatchedText)
.badge(showUnwatchedFeedBadges ? feedCount.unwatchedText : nil)
.contextMenu {
playUnwatchedButton
toggleWatchedButton

View File

@ -7,6 +7,7 @@ struct BrowsingSettings: View {
@Default(.roundedThumbnails) private var roundedThumbnails
#endif
@Default(.accountPickerDisplaysAnonymousAccounts) private var accountPickerDisplaysAnonymousAccounts
@Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges
#if os(iOS)
@Default(.homeRecentDocumentsItems) private var homeRecentDocumentsItems
@Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing
@ -223,6 +224,12 @@ struct BrowsingSettings: View {
#endif
Toggle("Show anonymous accounts", isOn: $accountPickerDisplaysAnonymousAccounts)
Toggle("Show unwatched feed badges", isOn: $showUnwatchedFeedBadges)
.onChange(of: showUnwatchedFeedBadges) { newValue in
if newValue {
FeedModel.shared.calculateUnwatchedFeed()
}
}
}
Toggle("Open channels with description expanded", isOn: $expandChannelDescription)

View File

@ -243,7 +243,7 @@ struct SettingsView: View {
private var windowHeight: Double {
switch selection {
case .browsing:
return 820
return 840
case .player:
return 450
case .controls:

View File

@ -9,6 +9,7 @@ struct ChannelsView: View {
@ObservedObject private var feedCount = UnwatchedFeedCountModel.shared
@Default(.showCacheStatus) private var showCacheStatus
@Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges
var body: some View {
List {
@ -26,7 +27,7 @@ struct ChannelsView: View {
}
}
.backport
.badge(feedCount.unwatchedByChannelText(channel))
.badge(showUnwatchedFeedBadges ? feedCount.unwatchedByChannelText(channel) : nil)
}
.contextMenu {
if subscriptions.isSubscribing(channel.id) {