Skip to content

Move notifications page to fully client-side API rendering#6235

Merged
dmetzner merged 2 commits intodevelopfrom
notifications-client-rendering
Mar 2, 2026
Merged

Move notifications page to fully client-side API rendering#6235
dmetzner merged 2 commits intodevelopfrom
notifications-client-rendering

Conversation

@dmetzner
Copy link
Copy Markdown
Collaborator

@dmetzner dmetzner commented Mar 2, 2026

Summary

  • Migrates the notifications page from hybrid server/client rendering to fully API-driven client-side rendering via GET /api/notifications
  • Simplifies NotificationController to a thin auth-checking shell that renders an empty template
  • Deletes 8 dead per-type Twig notification templates (templates/User/Notification/Type/)
  • Updates JS to fetch all notification data via API on page load with per-tab cursor-based pagination

Test plan

  • All 23 web-notifications Behat scenarios pass (271 steps)
  • Both broadcast notification Behat scenarios pass (28 steps)
  • All 13 API notifications Behat scenarios pass (115 steps)
  • PHPUnit NotificationsApiTest passes (9 tests, 17 assertions)
  • PHPStan clean, PHP CS Fixer clean
  • Manual: open notifications page, verify notifications load for all tabs
  • Manual: verify infinite scroll loads more notifications
  • Manual: verify clicking notifications redirects correctly

🤖 Generated with Claude Code

dmetzner and others added 2 commits March 2, 2026 08:23
The notifications page previously used a hybrid approach: server-rendered
initial notifications via Twig templates, with JS handling only tab
switching and infinite scroll. This migrates to a fully API-driven
approach where all notification data is fetched via GET /api/notifications.

- Simplify NotificationController to only check auth and render empty shell
- Remove server-rendered notification loop from Twig template
- Delete 8 per-type Twig templates (Base, Like, Comment, Follow, etc.)
- Update JS to fetch initial "All" tab data via API on page load
- Add event delegation for click handling on dynamically rendered items
- Add per-tab cursor tracking for proper pagination state
- Update Behat tests to wait for AJAX after navigating to notifications page
- Update CLAUDE.md with Docker build/cache and DOMContentLoaded learnings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Addresses code review findings:
- Add escapeHtml() for all user-controlled data in template literals (XSS fix)
- Replace 5 boolean tab flags with single activeTab string + TAB_CONFIG array
- Data-driven tab click handlers and scroll handler (eliminates copy-paste)
- Per-type fetchActive lock instead of global boolean (fixes cross-tab blocking)
- Add requestAnimationFrame throttle to scroll handler
- Use ApiFetch.run() instead of raw generateAuthenticatedFetch() (proper error handling)
- Simplify updateNoNotificationsPlaceholder with string interpolation
- Add early return in redirectUser after first branch
- Cache container DOM references in constructor
- Merge resetChips/resetColor into single data-driven loop

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.07%. Comparing base (f20edd1) to head (9aebd21).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
...ication/Controller/User/NotificationController.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #6235      +/-   ##
=============================================
+ Coverage      51.97%   52.07%   +0.10%     
+ Complexity      8204     8191      -13     
=============================================
  Files            739      739              
  Lines          26319    26264      -55     
=============================================
  Hits           13678    13678              
+ Misses         12641    12586      -55     
Flag Coverage Δ
behat 49.51% <0.00%> (+0.10%) ⬆️
phpunit 10.68% <0.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@dmetzner dmetzner merged commit d7eb8a0 into develop Mar 2, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant