@@ -447,42 +447,40 @@ open class EditingStack: Hashable, StoreDriverType {
447447
448448 assert ( Thread . isMainThread == false )
449449
450- commit { ( modifyingState : inout State ) in
450+ if let loadedState = state . mapIfPresent ( \ . loadedState ) {
451451
452- if let loadedState = state. mapIfPresent ( \. loadedState) {
453-
454- loadedState. ifChanged ( \. thumbnailImage) . do { image in
455-
456- modifyingState. loadedState!. previewFilterPresets = self . filterPresets. map {
452+ loadedState. ifChanged ( \. thumbnailImage) . do { image in
453+
454+ commit {
455+ $0. loadedState!. previewFilterPresets = self . filterPresets. map {
457456 PreviewFilterPreset ( sourceImage: image, filter: $0)
458457 }
459458 }
460-
461- loadedState. ifChanged ( \. currentEdit. filters) . do { currentEdit in
462-
463- self . debounceForCreatingCGImage. on { [ weak self] in
464-
465- guard let self = self else { return }
466-
467- let cgImageForCrop : CGImage = {
468- do {
469- return try Self . renderCGImageForCrop (
470- filters: currentEdit. makeFilters ( ) ,
471- source: . init( cgImage: loadedState. editingSourceCGImage) ,
472- orientation: loadedState. metadata. orientation
473- )
474- } catch {
475- assertionFailure ( )
476- return loadedState. editingSourceCGImage
477- }
478- } ( )
479-
480- self . commit {
481- $0. loadedState? . imageForCrop = cgImageForCrop
459+ }
460+
461+ loadedState. ifChanged ( \. currentEdit. filters) . do { currentEdit in
462+
463+ self . debounceForCreatingCGImage. on { [ weak self] in
464+
465+ guard let self = self else { return }
466+
467+ let cgImageForCrop : CGImage = {
468+ do {
469+ return try Self . renderCGImageForCrop (
470+ filters: currentEdit. makeFilters ( ) ,
471+ source: . init( cgImage: loadedState. editingSourceCGImage) ,
472+ orientation: loadedState. metadata. orientation
473+ )
474+ } catch {
475+ assertionFailure ( )
476+ return loadedState. editingSourceCGImage
482477 }
483-
478+ } ( )
479+
480+ self . commit {
481+ $0. loadedState? . imageForCrop = cgImageForCrop
484482 }
485-
483+
486484 }
487485
488486 }
0 commit comments