-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline Mode: Improve Post Settings #22863
Conversation
|
App Name | ![]() |
|
Configuration | Release-Alpha | |
Build Number | pr22863-cf313c6 | |
Version | 24.5 | |
Bundle ID | org.wordpress.alpha | |
Commit | cf313c6 | |
App Center Build | WPiOS - One-Offs #9274 |
|
App Name | ![]() |
|
Configuration | Release-Alpha | |
Build Number | pr22863-cf313c6 | |
Version | 24.5 | |
Bundle ID | com.jetpack.alpha | |
Commit | cf313c6 | |
App Center Build | jetpack-installable-builds #8318 |
Hey @kean 👋
|
Hey, @tiagomar. Yeah, I've noticed it too. I moved the PR to draft and will try a slightly different approach tomorrow. Btw, there are 4-6 UI tests we are planning to add in the scope of the project. |
We'll keep this change out of the scope for now. It's too risky, it deviates from the existing behavior too much, and is not necessarily required to fix the sync issues. |
3678f3a
to
b9e7b95
Compare
b9e7b95
to
cf313c6
Compare
/// | ||
/// - warning: Work-in-progress (kahu-offline-mode) | ||
@MainActor | ||
func _update(_ post: AbstractPost, changes: RemotePostUpdateParameters) async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the simplest possible form of updating the post: send diff, update the original
post with RemotePost
from the server. Keeps the local revision intact. It'll be required in a few places when working with published posts.
@@ -73,12 +73,12 @@ extension PostSettingsViewController { | |||
guard let media = MediaCoordinator.shared.addMedia(from: asset, to: apost) else { | |||
return | |||
} | |||
self.apost.featuredImage = media | |||
self.apost.featuredImage = try? self.apost.managedObjectContext?.existingObject(with: TaggedManagedObjectID(media)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I referred to in the description. When you add a featuredImage
, it gets added to viewContext
, so we have to get the instance in the temporary child context. The child context also automatically merges the changes from viewContext
to allow the screen to show the updated status of the Media
asset. This is probably the only complication with child contexts.
|
||
/// - note: Deprecated (kahu-offline-mode) | ||
private func _buttonSaveTapped() { | ||
saveChangesToParentContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's slightly different from the previous production behavior – it's now fully offline-first and it should be OK. It means that the "Save" is now also offline-first. I hope we don't even end up shipping this and be ready for 24.6 release.
if (self.isStandalone) { | ||
if ((self.isBeingDismissed || self.parentViewController.isBeingDismissed) && !self.isStandaloneEditorDismissingAfterSave) { | ||
// TODO: Implement it using a ViewModel or a child context to eliminate the risk of accidently saving the changes without uploading them | ||
[self.apost.managedObjectContext refreshObject:self.apost mergeChanges:NO]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To discard the changes, you no longer need to do anything thanks to the child context. This is probably why it's really worth it – we no longer have to worry about accidentally saving the changes to the database without committing them to the server. This will be used in the upcoming changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kean 👋 I tested the flows and found a few issues.
When I make changes to a post setting and go back to the editor, the "Update" button is disabled. Tapping the more button enables the "Update" button.
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-03-28.at.14.19.50.mp4
Verify that password-protected visibility does not crash in the standalone editor
If I access post settings from the post list context menu, this flow crashes.
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-03-28.at.14.25.50.mp4
If I access post settings from the editor, change to password protected visibility, I am not able to update my post with the new post settings.
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-03-28.at.14.23.28.mp4
Verify that "Save" is enabled only if there are any changes (undoing a change will disable the button)
If I undo a change for tags, the "Save" button is not disabled.
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-03-28.at.14.20.16.mp4
It's a production issue. It's on my stretch-task list. This has the same root cause:
I initially put it on the list of tests, but forgot to remove it once I decided not to fix it just yet. It's anther production issue. It's an assertion, so it doest' crash in production, but does in the debug mode.
Looking into it – I'll push a fix. |
Hmm, I can't reproduce it. I'll put in on the list to check and fix later. |
Closed in favor of #22934 |
This PR improves Post Settings in multiple ways by introducing a child context as a scratchpad for changes. The only complication is due to the relationships. For example, when you add a category, its added in the
viewContext
, so we have to get the same object in the scratchpad.Known Issues
In this PR, I want to make sure we get the bigger ideas right. There are a couple of known issues:
publicizeMessage
and social integration not encoded in the patch parameters""
instead ofnull
)I have a list of those and I suggest not focusing on the individual fields for now. We'll do a full test before merging the feature branch.
Changes
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-03-19.at.16.51.01.mp4
To test:
viewContext
, so it was a bit tricky to support): you can select new categories, add new categories, and the categories are pre-selected after re-opening the picker.syncPublishing
feature flag and perform regression test of the settingsKnown Issues
status
updates from the Post Settings are handled in the upcoming PRRegression Notes
PR submission checklist:
RELEASE-NOTES.txt
if necessary.Testing checklist: