mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-03-24 02:11:16 +01:00
feat: save memo before dismissing canvas view
This commit is contained in:
@@ -203,15 +203,15 @@ extension GraphicContext {
|
||||
withPersistence(\.backgroundContext) { [penStroke] context in
|
||||
penStroke.object?.bounds = penStroke.bounds
|
||||
try context.saveIfNeeded()
|
||||
if let object = penStroke.object {
|
||||
context.refresh(object, mergeChanges: false)
|
||||
}
|
||||
context.refreshAllObjects()
|
||||
}
|
||||
} else if let eraserStroke = currentStroke.stroke(as: EraserStroke.self) {
|
||||
eraserStroke.saveQuads()
|
||||
eraserStrokes.insert(eraserStroke)
|
||||
withPersistence(\.backgroundContext) { context in
|
||||
withPersistence(\.backgroundContext) { [eraserStroke] context in
|
||||
eraserStroke.object?.bounds = eraserStroke.bounds
|
||||
try context.saveIfNeeded()
|
||||
context.refreshAllObjects()
|
||||
}
|
||||
}
|
||||
previousStroke = currentStroke
|
||||
|
||||
@@ -128,15 +128,15 @@ struct Toolbar: View {
|
||||
}
|
||||
|
||||
func closeMemo() {
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
withAnimation {
|
||||
canvas.state = .closing
|
||||
}
|
||||
withPersistence(\.backgroundContext) { context in
|
||||
try? context.saveIfNeeded()
|
||||
DispatchQueue.main.async {
|
||||
canvas.state = .closing
|
||||
}
|
||||
withPersistenceSync(\.viewContext) { context in
|
||||
try context.saveIfNeeded()
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
canvas.state = .closed
|
||||
withAnimation {
|
||||
canvas.state = .closed
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user