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

Fix off-by-one error in post likes #23912

Merged
merged 5 commits into from
Dec 19, 2024
Merged

Fix off-by-one error in post likes #23912

merged 5 commits into from
Dec 19, 2024

Conversation

kean
Copy link
Contributor

@kean kean commented Dec 19, 2024

Fixes #23911.

To address it, I decided to simplify it with the following changes:

  • Remove the animations as they were adding little value as you don't interact with this view or even see it when adding likes
  • Use unidirectional data flow by observing a post object, which is the source of truth for number of likes. Remove the two properties that were storing the number of likes resulting in duplicated state.

In addition, I made a couple of other formatting and other improvements, including rewriting some of the code to use pure functions.

Screenshot 2024-12-19 at 11 45 33 AM Screenshot 2024-12-19 at 11 45 19 AM
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-12-19.at.13.30.40.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-12-19.at.13.30.10.mp4

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 the Reader label Dec 19, 2024
@kean kean added this to the 25.6 ❄️ milestone Dec 19, 2024
@kean kean requested a review from crazytonyli December 19, 2024 18:35
@dangermattic
Copy link
Collaborator

dangermattic commented Dec 19, 2024

1 Warning
⚠️ This PR is assigned to the milestone 25.6 ❄️. 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

@kean kean mentioned this pull request Dec 19, 2024

/// Convenience property that adds up the total likes and self like for display purposes.
var totalLikesForDisplay: Int {
return displaysSelfAvatar ? totalLikes + 1 : totalLikes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

displaysSelfAvatar was the root cause, as the selfAvatarImageView hidden value was being updated after showing the a number of likes. So, there was an easier fix, but I opted to refactor it to make it completely reliable as there could be other issues.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 19, 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 Numberpr23912-706e6e8
Version25.6
Bundle IDorg.wordpress.alpha
Commit706e6e8
App Center BuildWPiOS - One-Offs #11213
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 Dec 19, 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 Numberpr23912-706e6e8
Version25.6
Bundle IDcom.jetpack.alpha
Commit706e6e8
App Center Buildjetpack-installable-builds #10251
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@kean kean added this pull request to the merge queue Dec 19, 2024
Merged via the queue into trunk with commit d634ed4 Dec 19, 2024
25 checks passed
@kean kean deleted the fix/number-of-likes-off-by-one branch December 19, 2024 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Off by one in likes
4 participants