-
Notifications
You must be signed in to change notification settings - Fork 854
Forms: Refactor feedback status tracking and add unread count refresh #46505
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
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors the feedback status tracking system to handle broader status transitions beyond just spam marking, with a focus on maintaining accurate unread counts. The main change is renaming and expanding track_spam_status_change to track_feedback_status_change, while adding automatic unread count recalculation when feedback post status changes to/from 'publish'.
Key changes:
- Refactored status tracking to handle any feedback post status transition
- Integrated unread count refresh when feedback is published or unpublished
- Extracted spam meta tracking to a private helper method for better code organization
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| class-contact-form-plugin.php | Refactors spam tracking into broader feedback status tracking, deprecates old method, adds private helpers for spam meta and unread count recalculation |
| Contact_Form_Plugin_Test.php | Adds comprehensive unit tests covering spam meta tracking, unread count updates, read/unread handling, and non-feedback post filtering |
| actions.tsx | Adds optimistic updates for sidebar unread counter when feedback moves to/from spam or trash |
| changelog/fix-unread-count-refresh | Documents the change as a patch-level refactoring |
projects/packages/forms/src/contact-form/class-contact-form-plugin.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/src/contact-form/class-contact-form-plugin.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Show resolved
Hide resolved
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Show resolved
Hide resolved
Code Coverage SummaryCoverage changed in 3 files.
1 file is newly checked for coverage.
|
e8e909b to
a9949ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
projects/packages/forms/src/dashboard/inbox/stage/process-status-change.ts
Outdated
Show resolved
Hide resolved
| const promises = await Promise.allSettled( | ||
| items.map( ( { id } ) => apiCall( id ) as Promise< { id: number } > ) |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The withTimeout wrapper has been removed from the API calls when extracting processStatusChange to a separate file. The original implementation wrapped apiCall with withTimeout (as seen in the deleted code with "withTimeout( apiCall( id ) )"), which provided timeout protection for network requests. Without this wrapper, API calls may hang indefinitely if the network is disabled or unresponsive. Either re-add the withTimeout wrapper in this function, or ensure the apiCall parameter is already wrapped with timeout protection before being passed to processStatusChange.
projects/packages/forms/src/contact-form/class-contact-form-plugin.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/src/contact-form/class-contact-form-plugin.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
projects/packages/forms/src/dashboard/inbox/stage/process-status-change.ts
Show resolved
Hide resolved
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/src/contact-form/class-contact-form-plugin.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
projects/packages/forms/tests/js/dashboard/inbox/actions-menu-counter.test.js
Outdated
Show resolved
Hide resolved
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/forms/src/contact-form/class-contact-form-plugin.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
vianasw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work with the refactor. The code looks reasonable and all the tests suggested in the PR are working fine. However, when I click on 'Undo' after marking an unread feedback as spam, the counter doesn't get updated.
Replaces track_spam_status_change with track_feedback_status_change to handle feedback post status transitions, including spam and publish. Adds private helpers for spam meta and unread count recalculation. Comprehensive unit tests added for feedback status changes, spam meta updates, unread count recalculation, and non-feedback post handling.
…ugin.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Moved the processStatusChange logic from actions.tsx to a new process-status-change.ts file for better modularity and maintainability. Updated imports accordingly and enhanced tests to cover error handling and revert logic for menu counter updates.
8c97749 to
aecf11a
Compare
Fixes FORMS-NEW
Proposed changes:
track_spam_status_changetotrack_feedback_status_changeto handle broader feedback post status transitionstrack_spam_statushelper methodtrack_recount_unreadmethod to trigger unread count updates on status changestrack_spam_status_changemethod with backward compatibilityOther information:
Jetpack product discussion
See p1767878614114049-slack-C052XEUUBL4
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Prerequisites
Test 1: Unread count updates when feedback status changes
Test 2: Spam meta tracking
Test 3: Read feedback doesn't trigger recount
Test 4: Unit tests
Run the new unit tests: