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

Offline Mode: Deduplicate new posts #23173

Merged
merged 23 commits into from May 9, 2024
Merged

Conversation

momo-ozawa
Copy link
Contributor

@momo-ozawa momo-ozawa commented May 8, 2024

Fixes pe7hp4-N2-p2#comment-328

Description

  • Fixes duplicate posts from appearing in the posts list when refresh and sync (upon regaining connectivity) happens in parallel, by sending a UUID as a foreign key in the metadata

How to test

Precondition: set a response breakpoint on https://public-api.wordpress.com/rest/v1.2/sites/*/posts/new?context=edit&locale=en

  • Create and save a new draft
  • Hit the breakpoint
  • ✅ Verify the foreignID is sent
  • Pull to refresh
  • ✅ Verify that duplicate posts don't appear when refresh and sync (upon regaining connectivity) happens in parallel
  • Release the breakpoint
Screen.Recording.2024-05-09.at.11.05.44.mov

Regression Notes

  1. Potential unintended areas of impact
    n/a

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

  3. What automated tests I added (or what prevented me from doing so)
    n/a

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.

@dangermattic
Copy link
Collaborator

dangermattic commented May 8, 2024

2 Warnings
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 24.8 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 8, 2024

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 Numberpr23173-9a2fb24
Version24.8
Bundle IDorg.wordpress.alpha
Commit9a2fb24
App Center BuildWPiOS - One-Offs #9858
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 8, 2024

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 Numberpr23173-9a2fb24
Version24.8
Bundle IDcom.jetpack.alpha
Commit9a2fb24
App Center Buildjetpack-installable-builds #8906
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

WordPress/Classes/RemotePost+Metadata.swift Outdated Show resolved Hide resolved
WordPress/Classes/Services/PostHelper.m Outdated Show resolved Hide resolved
WordPress/Classes/Services/PostHelper.m Outdated Show resolved Hide resolved
WordPress/Classes/Services/PostRepository.swift Outdated Show resolved Hide resolved
WordPress/Classes/Services/PostHelper.m Outdated Show resolved Hide resolved
WordPress/Classes/Models/Blog+Post.swift Outdated Show resolved Hide resolved
MIGRATIONS.md Outdated Show resolved Hide resolved
@momo-ozawa momo-ozawa requested a review from kean May 9, 2024 10:58
@momo-ozawa
Copy link
Contributor Author

Hi @kean, can I get a re-review?

Here's a video of setting a breakpoint on the posts/new response, then refreshing the list. It now works as expected.

Screen.Recording.2024-05-09.at.11.05.44.mov

Copy link
Contributor

@kean kean left a comment

Choose a reason for hiding this comment

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

Hey, works as expected, but I left two more small comments.

@momo-ozawa momo-ozawa requested a review from kean May 9, 2024 14:22
@momo-ozawa
Copy link
Contributor Author

Thanks @kean - I've addressed your comments 🙇‍♀️

@kean
Copy link
Contributor

kean commented May 9, 2024

Tested:

  • Posts, self-hosted - 🟢
  • Posts, wp.com - 🟢
  • Pages - 🔴

The deduplication doesn't work for pages because the app doesn't send the metadata in that case, which is a production behavior. I think it might be worth fixing it separately (and in trunk?).

@momo-ozawa momo-ozawa enabled auto-merge May 9, 2024 14:34
@momo-ozawa momo-ozawa merged commit c338e16 into release/24.8 May 9, 2024
23 of 24 checks passed
@momo-ozawa momo-ozawa deleted the task/dedup-via-metadata branch May 9, 2024 17:51
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.

None yet

4 participants