Save or clear last draft URL from based on change in post status

This commit is contained in:
Angelo Stavrow 2020-11-04 14:13:23 -05:00
parent c1ed348c96
commit d3e89e2a45
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -136,6 +136,13 @@ struct PostEditorView: View {
model.move(post: post, from: selectedCollection, to: newCollection) model.move(post: post, from: selectedCollection, to: newCollection)
} }
}) })
.onChange(of: post.status, perform: { value in
if value != PostStatus.published.rawValue {
self.model.editor.saveLastDraft(post)
} else {
self.model.editor.clearLastDraft()
}
})
.onAppear(perform: { .onAppear(perform: {
self.selectedCollection = collections.first { $0.alias == post.collectionAlias } self.selectedCollection = collections.first { $0.alias == post.collectionAlias }
if post.status != PostStatus.published.rawValue { if post.status != PostStatus.published.rawValue {