mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Clear lastDraft if selectedPost has published status
This commit is contained in:
parent
5bcd3185bf
commit
44fd09aa33
@ -15,7 +15,11 @@ class WriteFreelyModel: ObservableObject {
|
||||
@Published var selectedPost: WFAPost? {
|
||||
didSet {
|
||||
if let post = selectedPost {
|
||||
if post.status != PostStatus.published.rawValue { editor.setLastDraft(post) }
|
||||
if post.status != PostStatus.published.rawValue {
|
||||
editor.setLastDraft(post)
|
||||
} else {
|
||||
editor.clearLastDraft()
|
||||
}
|
||||
} else {
|
||||
editor.clearLastDraft()
|
||||
}
|
||||
|
@ -111,6 +111,10 @@ struct PostEditorView: View {
|
||||
DispatchQueue.main.async {
|
||||
model.editor.setLastDraft(post)
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
model.editor.clearLastDraft()
|
||||
}
|
||||
}
|
||||
})
|
||||
.onDisappear(perform: {
|
||||
|
@ -140,6 +140,10 @@ struct PostEditorView: View {
|
||||
DispatchQueue.main.async {
|
||||
LocalStorageManager().saveContext()
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
model.editor.clearLastDraft()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user