Add selectedPost published property to WF model

This commit is contained in:
Angelo Stavrow 2020-08-31 16:35:45 -04:00
parent 45b6fb533c
commit 30b527daa4
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 12 additions and 1 deletions

View File

@ -7,7 +7,7 @@ enum PostStatus {
case published
}
class Post: Identifiable, ObservableObject {
class Post: Identifiable, ObservableObject, Hashable {
@Published var wfPost: WFPost
@Published var status: PostStatus
@Published var collection: PostCollection
@ -39,6 +39,16 @@ class Post: Identifiable, ObservableObject {
}
}
extension Post {
static func == (lhs: Post, rhs: Post) -> Bool {
return lhs.id == rhs.id
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
#if DEBUG
let testPost = Post(
title: "Test Post Title",

View File

@ -10,6 +10,7 @@ class WriteFreelyModel: ObservableObject {
@Published var store = PostStore()
@Published var collections = CollectionListModel(with: [])
@Published var isLoggingIn: Bool = false
@Published var selectedPost: Post?
private var client: WFClient?
private let defaults = UserDefaults.standard