Set new local post as selectedPost in WriteFreelyModel

This commit is contained in:
Angelo Stavrow 2020-09-15 12:03:34 -04:00
parent a791f4f50e
commit 7fd7b43755
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
3 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import SwiftUI
struct PostListFilteredView: View {
@EnvironmentObject var model: WriteFreelyModel
var fetchRequest: FetchRequest<WFAPost>
init(filter: String?, showAllPosts: Bool) {
@ -28,7 +29,11 @@ struct PostListFilteredView: View {
var body: some View {
List(fetchRequest.wrappedValue, id: \.self) { post in
NavigationLink(destination: PostEditorView(post: post)) {
NavigationLink(
destination: PostEditorView(post: post),
tag: post,
selection: $model.selectedPost
) {
PostCellView(post: post)
}
}

View File

@ -111,6 +111,7 @@ struct PostListView: View {
DispatchQueue.main.async {
LocalStorageManager().saveContext()
}
model.selectedPost = managedPost
}
}

View File

@ -7,12 +7,12 @@
<key>WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
<key>WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>