Conversation
The radial, linear, spot-heal, beauty, and color-mixer reset routines duplicated PhotoAdjustments default values inside PhotoLibraryStore. Those magic numbers also live in the struct defaults, the memberwise init, and the decoder, so a default could silently drift out of sync across call sites. Move the reset behavior onto PhotoAdjustments as pure mutating methods (resetRadialAdjustment, resetLinearAdjustment, resetSpotHeal, resetLocalAdjustments, resetBeautyAdjustments, resetColorMixer) that derive their values from PhotoAdjustments.neutral, and have the store delegate to them. Add model unit tests covering each reset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The radial, linear, spot-heal, beauty, and color-mixer reset routines in
PhotoLibraryStoreeach inlinedPhotoAdjustments' default values as magic numbers (e.g.radialRadius = 0.35,spotHealRadius = 0.06,linearEndY = 0.65). Those same defaults already live in three other places — the struct's stored-property defaults, the memberwiseinit, and theDecodableinitializer — so a default could silently drift out of sync between the editor's reset buttons and the actual neutral state.This PR moves the reset behavior onto
PhotoAdjustmentsitself as pure mutating methods that derive their values fromPhotoAdjustments.neutral, and has the store delegate to them.Changes
PhotoAsset.swift— addresetRadialAdjustment(),resetLinearAdjustment(),resetSpotHeal(),resetLocalAdjustments(),resetBeautyAdjustments(), andresetColorMixer()onPhotoAdjustments. The local/radial/linear/spot methods source their values fromPhotoAdjustments.neutralso there is a single source of truth.PhotoLibraryStore.swift— the sixresetSelected…methods now delegate to the new model methods instead of repeating the field-by-field resets (net −48 lines of duplicated magic numbers).LumaModelTests.swift— add 6 tests verifying each reset restores the right fields to their neutral defaults while leaving unrelated edits untouched.Behavior
No user-facing behavior change — this is a refactor that removes duplication and adds test coverage to logic that was previously only exercised through the Core Image pipeline.
Testing
I could not compile or run
swift testin this environment (Linux, no Swift toolchain; the app targets macOS-only AppKit/SwiftUI/Core Image). The change is deliberately scoped to pure value-type logic so it is fully covered by the existing model test target — please runswift teston macOS to confirm.https://claude.ai/code/session_01KhYaXvEGDKh26h6A5LdoAW
Generated by Claude Code