Skip to content

Conversation

@nbradbury
Copy link
Contributor

Partially addresses CMM-1037

As a companion to this previous PR, this PR updates the page list empty view to remove the outdated illustrations and adds a subtitle to the "Published pages" empty list.

To test, spin up a site without any pages, or delete all the pages in an existing site, and verify the empty views work as expected.

Note that your published page list may shows this homepage item:

homepage

If it does, modify this line to just it.

Screen_recording_20251210_131220.mp4

@nbradbury
Copy link
Contributor Author

@claude

@claude
Copy link
Contributor

claude bot commented Dec 10, 2025

Claude finished @nbradbury's task in 1m 42s —— View job


Code Review Complete ✓

I've conducted a comprehensive code review of this PR. Overall, the implementation is clean and well-structured. Here are my findings:

✅ Positive Observations

  1. Clean Refactoring: The PR successfully removes the outdated illustration and simplifies the Empty data class by removing the isImageVisible parameter
  2. Consistent Pattern: The change to use named parameters (titleResource, subtitleResource) improves code readability
  3. Good Scope: The changes are focused and address the stated objective without unnecessary modifications
  4. Resource Management: Properly removes the unused drawable resource (img_illustration_pages_104dp.xml)

🐛 Critical Issue: Logic Error in PageItemViewHolder.kt

Location: PageItemViewHolder.kt:347-352

There's a critical bug in the subtitle visibility logic:

pageItem.subtitleResource?.let { subtitleResource ->
    emptyView.subtitle.text = emptyView.resources.getString(subtitleResource)
    emptyView.subtitle.visibility = View.VISIBLE
} ?: {
    emptyView.subtitle.visibility = View.GONE
}

Problem: The Elvis operator (?:) is followed by a lambda that's never executed. In Kotlin, let { } ?: { } doesn't work as intended here - the right-hand side lambda is just created but never called.

Fix: Remove the braces on the else clause:

pageItem.subtitleResource?.let { subtitleResource ->
    emptyView.subtitle.text = emptyView.resources.getString(subtitleResource)
    emptyView.subtitle.visibility = View.VISIBLE
} ?: run {
    emptyView.subtitle.visibility = View.GONE
}

Or use a more straightforward approach:

if (pageItem.subtitleResource != null) {
    emptyView.subtitle.text = emptyView.resources.getString(pageItem.subtitleResource)
    emptyView.subtitle.visibility = View.VISIBLE
} else {
    emptyView.subtitle.visibility = View.GONE
}

Impact: Currently, when subtitleResource is null, the subtitle visibility is never set to GONE, which could leave stale subtitles visible from previous views.

📝 Other Observations

  1. String Updates: The updated strings are more conversational and user-friendly:

    • "You haven't published any pages - yet!" (added dash and exclamation)
    • "Why not create one?" (new encouraging subtitle)
  2. Parameter Naming: Renaming textResourcetitleResource is a good improvement for semantic clarity

  3. Testing: The existing test file (PageListViewModelTest.kt) doesn't appear to have tests for empty states with subtitles. Consider adding a test case to verify the new subtitle functionality works correctly for published pages.

🔍 Code Quality Check

  • ✅ Line length: All lines are under 120 characters (CLAUDE.md requirement)
  • ✅ No use of deprecated APIs
  • ✅ Proper null safety handling (except for the bug noted above)
  • ✅ Consistent code style with existing codebase
  • ⚠️ No new tests added for the subtitle feature

🎯 Recommendations

  1. [CRITICAL] Fix the subtitle visibility logic bug in PageItemViewHolder.kt:347-352 (see inline comment)
  2. [RECOMMENDED] Add unit tests to verify the subtitle appears for empty published pages and doesn't appear for other empty states
  3. [OPTIONAL] Consider testing on a device to ensure the empty view displays correctly without the illustration

@dangermattic
Copy link
Collaborator

dangermattic commented Dec 10, 2025

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

Comment on lines 347 to 352
pageItem.subtitleResource?.let { subtitleResource ->
emptyView.subtitle.text = emptyView.resources.getString(subtitleResource)
emptyView.subtitle.visibility = View.VISIBLE
} ?: {
emptyView.subtitle.visibility = View.GONE
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Critical Bug: This Elvis operator with a lambda doesn't work as expected. The lambda { emptyView.subtitle.visibility = View.GONE } is created but never executed.

Current behavior: When subtitleResource is null, nothing happens, leaving the subtitle potentially visible from a previous view.

Suggested fix:

Suggested change
pageItem.subtitleResource?.let { subtitleResource ->
emptyView.subtitle.text = emptyView.resources.getString(subtitleResource)
emptyView.subtitle.visibility = View.VISIBLE
} ?: {
emptyView.subtitle.visibility = View.GONE
}
pageItem.subtitleResource?.let { subtitleResource ->
emptyView.subtitle.text = emptyView.resources.getString(subtitleResource)
emptyView.subtitle.visibility = View.VISIBLE
} ?: run {
emptyView.subtitle.visibility = View.GONE
}

Or use a simpler if/else:

if (pageItem.subtitleResource != null) {
    emptyView.subtitle.text = emptyView.resources.getString(pageItem.subtitleResource)
    emptyView.subtitle.visibility = View.VISIBLE
} else {
    emptyView.subtitle.visibility = View.GONE
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This Elvis operator with a lambda doesn't work as expected.

🤦

Fixed in 755d3ca

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 10, 2025

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

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 10, 2025

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

@nbradbury nbradbury requested a review from adalpari December 10, 2025 19:35
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 43.75000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.09%. Comparing base (edb1fc8) to head (c54c3ba).

Files with missing lines Patch % Lines
...press/android/viewmodel/pages/PageListViewModel.kt 0.00% 5 Missing ⚠️
...droid/viewmodel/pages/PageParentSearchViewModel.kt 50.00% 2 Missing ⚠️
...ess/android/viewmodel/pages/SearchListViewModel.kt 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22413      +/-   ##
==========================================
- Coverage   39.09%   39.09%   -0.01%     
==========================================
  Files        2207     2207              
  Lines      106858   106864       +6     
  Branches    15159    15159              
==========================================
+ Hits        41776    41778       +2     
- Misses      61566    61570       +4     
  Partials     3516     3516              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nbradbury nbradbury marked this pull request as ready for review December 10, 2025 20:06
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.

4 participants