Offline Mode: Fix an issue with restore revisions not clearing media uploads
Fix an issue with "Restore Revision" feature not clearing media uploads. This issue is especially problematic if the post had media with terminal errors.
To test:
- Mocking: make sure all media uploads fail
- Open a draft post that has a couple of saved revisions ("History")
- Add an image to the post and tap "Save as Draft"
- Re-open the post for editing
- Open "History" (revisions)
- Load a revision that had no images
- Tap "Save as Draft"
- β Verify that the post got uploaded
https://github.com/wordpress-mobile/WordPress-iOS/assets/1567433/f6a41c00-3553-4814-9957-a96166d8b5ac
Discussion
We'll might run into more issues due to the current media upload architecture, its relation to post content, and the fact that you can now open drafts with changes that are still syncing for editing. The problem is that the media is closely tied to the content. During sync, PostCoordinator updates the post content whenever a media upload complete (this is an existing behavior). It breaks the invariant that the saved revisions are immutable. Here's one problematic scenario:
- Create and save a draft post
- Save a new revision with an image (upload is pending & slow)
- Open the post for editing but change nothing
- Wait until the image upload completes
- Tap "Back"
Expected behavior: the editor is closed Observed behavior: the editor shows a "Discard Change" confirmation dialog
Note: this is theoretical; I haven't yet tested it.
Regression Notes
- Potential unintended areas of impact: Post Editor & Media Uploads
- What I did to test those areas of impact (or what existing automated tests I relied on): n/a
- What automated tests I added (or what prevented me from doing so)
PR submission checklist:
- [ ] I have completed the Regression Notes.
- [ ] I have considered adding unit tests for my changes.
- [ ] I have considered adding accessibility improvements for my changes.
- [ ] I have considered if this change warrants user-facing release notes and have added them to
RELEASE-NOTES.txtif necessary.
Testing checklist:
- [ ] WordPress.com sites and self-hosted Jetpack sites.
- [ ] Portrait and landscape orientations.
- [ ] Light and dark modes.
- [ ] Fonts: Larger, smaller and bold text.
- [ ] High contrast.
- [ ] VoiceOver.
- [ ] Languages with large words or with letters/accents not frequently used in English.
- [ ] Right-to-left languages. (Even if translation isnβt complete, formatting should still respect the right-to-left layout)
- [ ] iPhone and iPad.
- [ ] Multi-tasking: Split view and Slide over. (iPad)
π² You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr23082-58da440 | |
| Version | 24.7 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 58da4402cbc6b816401b325e2b81e839f0ce553b | |
| App Center Build | WPiOS - One-Offs #9750 |
π² You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr23082-58da440 | |
| Version | 24.7 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 58da4402cbc6b816401b325e2b81e839f0ce553b | |
| App Center Build | jetpack-installable-builds #8796 |
Hi @kean π , I'm bumping this PR's milestone to 24.9 since I'm starting code freeze. Feel free to re-target this to the release branch if this is a blocker or intended for 24.8.