Add accounts to Sidebar

This commit is contained in:
Maurice Parker 2020-06-29 15:03:17 -05:00
parent 0886cffcff
commit 29b5f426fd
2 changed files with 20 additions and 4 deletions

View File

@ -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<Folder>() {
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
}

View File

@ -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)
}
}
}