From 29b5f426fd956ab9199229ad8064806fb64954d8 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 29 Jun 2020 15:03:17 -0500 Subject: [PATCH] Add accounts to Sidebar --- .../Shared/Sidebar/SidebarModel.swift | 18 ++++++++++++++++++ Multiplatform/Shared/Sidebar/SidebarView.swift | 6 ++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Multiplatform/Shared/Sidebar/SidebarModel.swift b/Multiplatform/Shared/Sidebar/SidebarModel.swift index 1375ab87a..19407a997 100644 --- a/Multiplatform/Shared/Sidebar/SidebarModel.swift +++ b/Multiplatform/Shared/Sidebar/SidebarModel.swift @@ -30,6 +30,24 @@ class SidebarModel: ObservableObject { } items.append(smartFeedControllerItem) + for account in AccountManager.shared.sortedActiveAccounts { + var accountItem = SidebarItem(account) + + for webFeed in account.topLevelWebFeeds { + accountItem.addChild(SidebarItem(webFeed, unreadCount: delegate.unreadCount(for: webFeed))) + } + + for folder in account.folders ?? Set() { + var folderItem = SidebarItem(folder, unreadCount: delegate.unreadCount(for: folder)) + for webFeed in folder.topLevelWebFeeds { + folderItem.addChild(SidebarItem(webFeed, unreadCount: delegate.unreadCount(for: webFeed))) + } + accountItem.addChild(folderItem) + } + + items.append(accountItem) + } + sidebarItems = items } diff --git a/Multiplatform/Shared/Sidebar/SidebarView.swift b/Multiplatform/Shared/Sidebar/SidebarView.swift index 0af760cb5..b67dfa340 100644 --- a/Multiplatform/Shared/Sidebar/SidebarView.swift +++ b/Multiplatform/Shared/Sidebar/SidebarView.swift @@ -14,10 +14,8 @@ struct SidebarView: View { var body: some View { List { - ForEach(sidebarModel.sidebarItems) { section in - OutlineGroup(sidebarModel.sidebarItems, children: \.children) { sidebarItem in - Text(sidebarItem.nameForDisplay) - } + OutlineGroup(sidebarModel.sidebarItems, children: \.children) { sidebarItem in + Text(sidebarItem.nameForDisplay) } } }