Skip to content
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

Refresh post when it is opened #23364

Closed
wants to merge 4 commits into from
Closed

Refresh post when it is opened #23364

wants to merge 4 commits into from

Conversation

kean
Copy link
Contributor

@kean kean commented Jun 17, 2024

This PR introduces the “post refresh” mechanism that was cut from the original scope of 24.9 to reduce the complexity. When you open a post for editing the app will now fetch the latest version of the post. Now if you tap a cached post before the list finishes refreshing, the app will guarantee that you will still see the latest version of the post. We hope that it will reduce the number of data conflicts when saving posts (post_repository_conflict_encountered).

There are a few caveats:

  • Refreshing a post takes time (expected range is ~200-500ms) and we don’t want to slow down opening the editor. This means that refresh has to happen in parallel with the editor initialization. If the post is already up to date, the editor doesn’t even need to reload.
  • You should be able to close the editor in case the refresh is taking too much time. If you do, and the request eventually fails, the app shouldn’t show the error snackbar.
  • The “Autosave Available” dialog should be shown based on the latest post content and after the refresh completes
  • The editor has it own loading animation. Ideally, we would tap into it, but with lack of an API, I ended up showing an overlay on top of it similar to what you find on wp.com

Out of the scope: adding support for “Not Found” scenario. It depends on fix/missing-original-assertion-when-updating-not-found-page, and I’d prefer to ship it in 25.2 once this change is proven.

refreshing-post-01.mp4

Scenario 1

  • (App) Open post list and wait until it fetches the latest posts
  • (Web) Modify and save one of the posts
  • (App) Select the modified post
  • ✅ Verify that the post shows the latest data

Comments in code:

  • This should be unreachable as [self] will be weak, but adding it just in case
    • We want to make sure that if you close the editor before the refresh finishes, it doesn’t affect other parts of that
  • When the editor opens, it immediately creates a revision, so we have to add this, unfortunately. If we end up rethinking the editor, this will be one thing to refactor.

To test:

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  3. 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.txt if 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)

@kean kean added this to the 25.2 milestone Jun 17, 2024
@kean kean requested a review from staskus June 17, 2024 20:30
@kean kean changed the title Fix/refresh post on open Refresh post when it is opened Jun 17, 2024
@wpmobilebot
Copy link
Contributor

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr23364-6a27273
Version25.1
Bundle IDcom.jetpack.alpha
Commit6a27273
App Center Buildjetpack-installable-builds #9225
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr23364-6a27273
Version25.1
Bundle IDorg.wordpress.alpha
Commit6a27273
App Center BuildWPiOS - One-Offs #10176
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@kean kean removed the request for review from staskus June 17, 2024 21:59
@kean kean marked this pull request as draft June 17, 2024 21:59
@kean kean modified the milestones: 25.2, Pending Jun 18, 2024
@kean
Copy link
Contributor Author

kean commented Sep 11, 2024

I'm going to close it for now because it will need to be largely re-implemented for the new editor.

@kean kean closed this Sep 11, 2024
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.

2 participants