@@ -2,6 +2,7 @@ import SwiftUI
22
33struct PostEditorView : View {
44 @EnvironmentObject var model : WriteFreelyModel
5+ @EnvironmentObject var errorHandling : ErrorHandling
56 @Environment ( \. horizontalSizeClass) var horizontalSizeClass
67 @Environment ( \. managedObjectContext) var moc
78 @Environment ( \. presentationMode) var presentationMode
@@ -40,6 +41,7 @@ struct PostEditorView: View {
4041 updatingTitleFromServer: $updatingTitleFromServer,
4142 updatingBodyFromServer: $updatingBodyFromServer
4243 )
44+ . withErrorHandling ( )
4345 }
4446 . navigationBarTitleDisplayMode ( . inline)
4547 . padding ( )
@@ -101,11 +103,6 @@ struct PostEditorView: View {
101103 } )
102104 . accessibilityHint ( Text ( " Open the system share sheet to share a link to this post " ) )
103105 . disabled ( post. postId == nil )
104- // Button(action: {
105- // print("Tapped 'Delete...' button")
106- // }, label: {
107- // Label("Delete…", systemImage: "trash")
108- // })
109106 if model. account. isLoggedIn && post. status != PostStatus . local. rawValue {
110107 Section ( header: Text ( " Move To Collection " ) ) {
111108 Label ( " Move to: " , systemImage: " arrowshape.zigzag.right " )
@@ -171,6 +168,16 @@ struct PostEditorView: View {
171168 self . model. editor. clearLastDraft ( )
172169 }
173170 } )
171+ . onChange ( of: model. hasError) { value in
172+ if value {
173+ if let error = model. currentError {
174+ self . errorHandling. handle ( error: error)
175+ } else {
176+ self . errorHandling. handle ( error: AppError . genericError ( ) )
177+ }
178+ model. hasError = false
179+ }
180+ }
174181 . onDisappear ( perform: {
175182 self . model. editor. clearLastDraft ( )
176183 if post. title. count == 0
0 commit comments