Skip to content

Commit 1ec48cb

Browse files
author
Thomas Taschauer
committed
fix no error shown on "back" while editing
1 parent 90a89f5 commit 1ec48cb

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

OpenDocumentReader/DocumentViewController.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ class DocumentViewController: UIViewController, DocumentDelegate, GADBannerViewD
160160
alert.addAction(UIAlertAction(title: NSLocalizedString("yes", comment: ""), style: .default, handler: { (_) in
161161
Analytics.logEvent("alert_unsaved_changes_yes", parameters: nil)
162162

163-
self.saveContent()
164-
self.closeCurrentDocument()
163+
self.saveContent() { (success) -> () in
164+
if (success) {
165+
self.closeCurrentDocument()
166+
}
167+
}
165168
}))
166169

167170
self.present(alert, animated: true, completion: nil)
@@ -194,7 +197,7 @@ class DocumentViewController: UIViewController, DocumentDelegate, GADBannerViewD
194197

195198
if document?.edit ?? false {
196199
alert.addAction(UIAlertAction(title: NSLocalizedString("menu_save", comment: ""), style: .default, handler: { (_) in
197-
self.saveContent()
200+
self.saveContent(completion: nil)
198201
}))
199202

200203
alert.addAction(UIAlertAction(title: NSLocalizedString("menu_discard_changes", comment: ""), style: .default, handler: { (_) in
@@ -229,7 +232,7 @@ class DocumentViewController: UIViewController, DocumentDelegate, GADBannerViewD
229232
doc.edit = true
230233
}
231234

232-
func saveContent() {
235+
func saveContent(completion: ((Bool) -> ())?) {
233236
Analytics.logEvent("menu_edit_save", parameters: nil)
234237

235238
guard let doc = document else {
@@ -249,7 +252,9 @@ class DocumentViewController: UIViewController, DocumentDelegate, GADBannerViewD
249252
color = .red
250253
}
251254

252-
self.showToast(controller: self, message: message, seconds: 1.5, color: color)
255+
self.showToast(controller: self, message: message, seconds: 1.5, color: color) {
256+
completion?(success)
257+
}
253258
}
254259
}
255260

0 commit comments

Comments
 (0)