diff --git a/Shared/PostCollection/CollectionSidebar.swift b/Shared/PostCollection/CollectionSidebar.swift index 4cba6db..983ef5a 100644 --- a/Shared/PostCollection/CollectionSidebar.swift +++ b/Shared/PostCollection/CollectionSidebar.swift @@ -1,30 +1,26 @@ import SwiftUI struct CollectionSidebar: View { @EnvironmentObject var postStore: PostStore @Binding var selectedCollection: PostCollection? private let collections = postCollections var body: some View { List { ForEach(collections) { collection in NavigationLink( destination: PostList(title: collection.title, posts: showPosts(for: collection)).tag(collection)) { Text(collection.title) } } } .listStyle(SidebarListStyle()) } - func showPosts(for collection: PostCollection) -> [Post] { - if collection == allPostsCollection { - return postStore.posts - } else { - return postStore.posts.filter { - $0.collection.title == collection.title - } - } +struct CollectionSidebar_Previews: PreviewProvider { + static var previews: some View { + CollectionSidebar() + .environmentObject(testPostStore) } }