mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-04-23 00:58:39 +02:00
feat: refresh objects
This commit is contained in:
@@ -52,6 +52,7 @@ final class GraphicContext: @unchecked Sendable {
|
|||||||
withPersistence(\.backgroundContext) { [stroke = deletedStroke] context in
|
withPersistence(\.backgroundContext) { [stroke = deletedStroke] context in
|
||||||
stroke?.stroke(as: PenStroke.self)?.object?.graphicContext = nil
|
stroke?.stroke(as: PenStroke.self)?.object?.graphicContext = nil
|
||||||
try context.saveIfNeeded()
|
try context.saveIfNeeded()
|
||||||
|
context.refreshAllObjects()
|
||||||
}
|
}
|
||||||
case .eraser:
|
case .eraser:
|
||||||
guard let eraserStroke = stroke.stroke(as: EraserStroke.self) else { return }
|
guard let eraserStroke = stroke.stroke(as: EraserStroke.self) else { return }
|
||||||
@@ -64,6 +65,8 @@ final class GraphicContext: @unchecked Sendable {
|
|||||||
penStroke.object?.erasers.remove(object)
|
penStroke.object?.erasers.remove(object)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try context.saveIfNeeded()
|
||||||
|
context.refreshAllObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previousStroke = nil
|
previousStroke = nil
|
||||||
@@ -82,6 +85,7 @@ final class GraphicContext: @unchecked Sendable {
|
|||||||
withPersistence(\.backgroundContext) { [weak self, penStroke] context in
|
withPersistence(\.backgroundContext) { [weak self, penStroke] context in
|
||||||
penStroke.object?.graphicContext = self?.object
|
penStroke.object?.graphicContext = self?.object
|
||||||
try context.saveIfNeeded()
|
try context.saveIfNeeded()
|
||||||
|
context.refreshAllObjects()
|
||||||
}
|
}
|
||||||
case .eraser:
|
case .eraser:
|
||||||
guard let eraserStroke = stroke.stroke(as: EraserStroke.self) else {
|
guard let eraserStroke = stroke.stroke(as: EraserStroke.self) else {
|
||||||
@@ -97,6 +101,7 @@ final class GraphicContext: @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try context.saveIfNeeded()
|
try context.saveIfNeeded()
|
||||||
|
context.refreshAllObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previousStroke = nil
|
previousStroke = nil
|
||||||
@@ -120,12 +125,14 @@ extension GraphicContext {
|
|||||||
withPersistenceSync(\.newBackgroundContext) { [_stroke] context in
|
withPersistenceSync(\.newBackgroundContext) { [_stroke] context in
|
||||||
guard let stroke = try? context.existingObject(with: id) as? StrokeObject else { return }
|
guard let stroke = try? context.existingObject(with: id) as? StrokeObject else { return }
|
||||||
_stroke.loadQuads(from: stroke, with: self)
|
_stroke.loadQuads(from: stroke, with: self)
|
||||||
|
context.refreshAllObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
withPersistence(\.backgroundContext) { [weak self] context in
|
withPersistence(\.backgroundContext) { [weak self] context in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
_stroke.loadQuads(with: self)
|
_stroke.loadQuads(with: self)
|
||||||
|
context.refreshAllObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ extension Canvas {
|
|||||||
func loadStrokes(_ bounds: CGRect) {
|
func loadStrokes(_ bounds: CGRect) {
|
||||||
withPersistence(\.backgroundContext) { [weak self, bounds] context in
|
withPersistence(\.backgroundContext) { [weak self, bounds] context in
|
||||||
self?.graphicContext.loadQuads(bounds, on: context)
|
self?.graphicContext.loadQuads(bounds, on: context)
|
||||||
|
context.refreshAllObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user