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