Post Settings: Save Infrastructure - #24624
Merged
Merged
Conversation
kean
commented
Jun 25, 2025
|
|
||
| func buttonSaveTapped() { | ||
| // Check if the post still exists | ||
| guard let context = post.managedObjectContext, |
Contributor
Author
There was a problem hiding this comment.
This generally should not happen, but the previous implementation also handles this scenario.
|
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
This PR introduces a new approach for savings and discarding changes in the "Post Settings" based not on Core Data, but on a modern value-type architecture that improves reliability, testability, and performance.
In the previous implementation, this screen had a lot of complexity due to the fact that it was applying changes directly to the Core Data post entities. It had to create a local revision of a post. Then on "Cancel", it had to delete it and also make sure it gets deleted if the app is terminated so we don't have unsaved changes in the store. It's just one example.
In the new version, we simply have this as a value type:
@Published var settings: PostSettings. When the user taps "Cancel", there is nothing we need to do or worry about. It's also easier to check if there are any changes thanks toHashable. You also no longer need to create or revert any post revisions.The old version had mixed responsibilities with UI updates, Core Data management, and business logic. The new has clear separation between data (
PostSettings), UI (PostSettingsView), and logic (PostSettingsViewModel).Recordings
I added a single temporary "slug" field for testing for now.
https://github.com/user-attachments/assets/60de4607-7c57-49d3-ad94-af5598a66b3f
https://github.com/user-attachments/assets/ee24e97e-ce1c-485a-bcdf-6f27df7f144b