Save/clear last draft based on status when loading post in editor

This commit is contained in:
Angelo Stavrow 2020-10-30 16:28:34 -04:00
parent 4ef40453d5
commit d129c0d0f9
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -137,6 +137,11 @@ struct PostEditorView: View {
}) })
.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 {
self.model.editor.saveLastDraft(post)
} else {
self.model.editor.clearLastDraft()
}
}) })
.onDisappear(perform: { .onDisappear(perform: {
if post.title.count == 0 if post.title.count == 0