From d3e89e2a4586364f9572ebd1dfbf2ea33470f39e Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Wed, 4 Nov 2020 14:13:23 -0500 Subject: [PATCH] Save or clear last draft URL from based on change in post status --- iOS/PostEditor/PostEditorView.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/iOS/PostEditor/PostEditorView.swift b/iOS/PostEditor/PostEditorView.swift index 9f67999..c29f796 100644 --- a/iOS/PostEditor/PostEditorView.swift +++ b/iOS/PostEditor/PostEditorView.swift @@ -136,6 +136,13 @@ struct PostEditorView: View { 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: { self.selectedCollection = collections.first { $0.alias == post.collectionAlias } if post.status != PostStatus.published.rawValue {