@@ -2,6 +2,7 @@ import SwiftUI
2
2
3
3
struct PostEditorView : View {
4
4
@EnvironmentObject var model : WriteFreelyModel
5
+ @EnvironmentObject var errorHandling : ErrorHandling
5
6
@Environment ( \. horizontalSizeClass) var horizontalSizeClass
6
7
@Environment ( \. managedObjectContext) var moc
7
8
@Environment ( \. presentationMode) var presentationMode
@@ -40,6 +41,7 @@ struct PostEditorView: View {
40
41
updatingTitleFromServer: $updatingTitleFromServer,
41
42
updatingBodyFromServer: $updatingBodyFromServer
42
43
)
44
+ . withErrorHandling ( )
43
45
}
44
46
. navigationBarTitleDisplayMode ( . inline)
45
47
. padding ( )
@@ -101,11 +103,6 @@ struct PostEditorView: View {
101
103
} )
102
104
. accessibilityHint ( Text ( " Open the system share sheet to share a link to this post " ) )
103
105
. disabled ( post. postId == nil )
104
- // Button(action: {
105
- // print("Tapped 'Delete...' button")
106
- // }, label: {
107
- // Label("Delete…", systemImage: "trash")
108
- // })
109
106
if model. account. isLoggedIn && post. status != PostStatus . local. rawValue {
110
107
Section ( header: Text ( " Move To Collection " ) ) {
111
108
Label ( " Move to: " , systemImage: " arrowshape.zigzag.right " )
@@ -171,6 +168,16 @@ struct PostEditorView: View {
171
168
self . model. editor. clearLastDraft ( )
172
169
}
173
170
} )
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
+ }
174
181
. onDisappear ( perform: {
175
182
self . model. editor. clearLastDraft ( )
176
183
if post. title. count == 0
0 commit comments