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

Refactors Notes to Kotlin #20200

Merged
merged 19 commits into from
Feb 20, 2024
Merged

Conversation

antonis
Copy link
Contributor

@antonis antonis commented Feb 16, 2024

Description

This PR:

  1. Converts the Notes model to Kotlin
  2. Removes unused code
  3. Replaces getters with lazy initialisation to limit json queries
  4. Removes synchronisation locks
  5. Cleans up the code and adds Kotlin idioms when possible

To Test:

  1. Open the notifications tab
  2. Scroll/Open notifications
  3. Like/Share notifications
  4. Change between tabs
  5. Verify that there are no changes in the behaviour of the app

Regression Notes

  1. Potential unintended areas of impact

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

    • Manual testing
  3. What automated tests I added (or what prevented me from doing so)

    • None at this stage

PR Submission Checklist:

  • I have completed the Regression Notes.
  • 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.
  • Talkback.
  • 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)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

@dangermattic
Copy link
Collaborator

dangermattic commented Feb 16, 2024

3 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class EnabledActions is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class NoteTimeGroup is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@antonis antonis changed the title Converts Notes to Kotlin Refactors Notes to Kotlin Feb 16, 2024
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 16, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20200-14c493d
Commit14c493d
Direct Downloadwordpress-prototype-build-pr20200-14c493d.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 16, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20200-14c493d
Commit14c493d
Direct Downloadjetpack-prototype-build-pr20200-14c493d.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented Feb 16, 2024

Codecov Report

Attention: 222 lines in your changes are missing coverage. Please review.

Comparison is base (688940e) 40.13% compared to head (14c493d) 40.16%.

Files Patch % Lines
...src/main/java/org/wordpress/android/models/Note.kt 0.00% 221 Missing ⚠️
...wordpress/android/datasets/NotificationsTable.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                          @@
##           feature/notifications_refresh_p1   #20200      +/-   ##
====================================================================
+ Coverage                             40.13%   40.16%   +0.02%     
====================================================================
  Files                                  1470     1470              
  Lines                                 67837    67787      -50     
  Branches                              11238    11240       +2     
====================================================================
  Hits                                  27228    27228              
+ Misses                                38112    38062      -50     
  Partials                               2497     2497              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mkevins mkevins left a comment

Choose a reason for hiding this comment

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

Thank you for tackling this! I've taken an early look while it is still in draft, and left a few comments. Please don't consider the suggestions as necessary for this Kotlinization PR, though, since the diff is already very large. With such a large class, it may make more sense to take a few steps toward migrating it.

private var mActions: JSONObject? = null
private var mLocalStatus: String? = null

private val mSyncLock = Any()
Copy link
Contributor

Choose a reason for hiding this comment

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

From what I could tell, we the current synchronized code doesn't require reentrancy. I wonder whether we could use a Mutex here instead? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I experimented a bit with using Mutex but this would require introducing coroutines and changes outside the scope of the Note model. Tbh I'm not sure if locking is needed in all cases when accessing the json object 🤔

@antonis antonis requested a review from jarvislin February 19, 2024 17:51
@antonis antonis requested a review from mkevins February 19, 2024 17:51
@antonis antonis marked this pull request as ready for review February 19, 2024 17:51
Copy link
Contributor

@jarvislin jarvislin left a comment

Choose a reason for hiding this comment

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

@antonis Thank you for converting the Note class to Kotlin. It's really helpful for us.
I've smoke tested the notification tab, the result is as expected, LGTM!

@antonis antonis merged commit 391ef87 into feature/notifications_refresh_p1 Feb 20, 2024
19 checks passed
@antonis antonis deleted the task/notes-to-kotlin branch February 20, 2024 09:52
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.

5 participants