Add setting to show/hide recents and limit number of recents shown

This commit is contained in:
Ricky Kresslein
2024-02-27 19:01:11 +01:00
parent 7b34c7e72b
commit 5559e78bc0
4 changed files with 99 additions and 3 deletions

View File

@@ -5,12 +5,14 @@ struct AppSidebarRecents: View {
var recents = RecentsModel.shared
@Default(.recentlyOpened) private var recentItems
@Default(.limitRecents) private var limitRecents
@Default(.limitRecentsAmount) private var limitRecentsAmount
var body: some View {
Group {
if !recentItems.isEmpty {
Section(header: Text("Recents")) {
ForEach(recentItems.reversed()) { recent in
ForEach(recentItems.reversed().prefix(limitRecents ? limitRecentsAmount : recentItems.count)) { recent in
Group {
switch recent.type {
case .channel:

View File

@@ -13,6 +13,7 @@ struct Sidebar: View {
@Default(.showDocuments) private var showDocuments
#endif
@Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges
@Default(.showRecents) private var showRecents
var body: some View {
ScrollViewReader { scrollView in
@@ -20,8 +21,10 @@ struct Sidebar: View {
mainNavigationLinks
if !accounts.isEmpty {
AppSidebarRecents()
.id("recentlyOpened")
if showRecents {
AppSidebarRecents()
.id("recentlyOpened")
}
if accounts.api.signedIn {
if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions {