Skip to content

Post Settings: Save Infrastructure - #24624

Merged
kean merged 10 commits into
feature/post-settingsfrom
task/add-save-infra
Jun 25, 2025
Merged

Post Settings: Save Infrastructure#24624
kean merged 10 commits into
feature/post-settingsfrom
task/add-save-infra

Conversation

@kean

@kean kean commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

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 to Hashable. 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

@kean kean added this to the 26.0 milestone Jun 25, 2025
@kean kean mentioned this pull request Jun 25, 2025
@kean
kean marked this pull request as ready for review June 25, 2025 21:20

func buttonSaveTapped() {
// Check if the post still exists
guard let context = post.managedObjectContext,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally should not happen, but the previous implementation also handles this scenario.

@kean
kean merged commit 89a2d79 into feature/post-settings Jun 25, 2025
3 of 27 checks passed
@kean
kean deleted the task/add-save-infra branch June 25, 2025 21:23
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant