diff --git a/Shared/PostCollection/CollectionListModel.swift b/Shared/PostCollection/CollectionListModel.swift index 8c07e46..4840011 100644 --- a/Shared/PostCollection/CollectionListModel.swift +++ b/Shared/PostCollection/CollectionListModel.swift @@ -1,18 +1,13 @@ import SwiftUI -struct CollectionListModel { +class CollectionListModel: ObservableObject { private(set) var userCollections: [PostCollection] = [] - private(set) var collectionsList: [PostCollection] - - init() { - collectionsList = [ allPostsCollection, draftsCollection ] - - #if DEBUG - userCollections = [ userCollection1, userCollection2, userCollection3 ] - #endif + @Published private(set) var collectionsList: [PostCollection] = [ allPostsCollection, draftsCollection ] + init(with userCollections: [PostCollection]) { for userCollection in userCollections { - collectionsList.append(userCollection) + self.userCollections.append(userCollection) } + collectionsList.append(contentsOf: self.userCollections) } }