ref(whats-new): Single data-fetch source and fix mark-seen edge cases#110269
ref(whats-new): Single data-fetch source and fix mark-seen edge cases#110269
Conversation
Move useFetchBroadcasts() from WhatsNewContent into the parent PrimaryNavigationWhatsNew so broadcasts and isPending are fetched once and passed down as props. This removes the duplicate hook call and separates the loading state from the empty state, which were previously conflated via broadcasts.length === 0. Also fix two related bugs: - Skip the mark-seen PUT request when unseenPostIds is empty, preventing a spurious request with an empty id list when all broadcasts are seen - Fix the onSuccess cache update fallback from [] to undefined so a missing cache entry is not replaced with an empty array Co-Authored-By: Claude <noreply@anthropic.com>
| setApiQueryData<Broadcast[]>( | ||
| queryClient, | ||
| makeBroadcastsQueryKey({organization}), | ||
| data => (data ? data.map(item => ({...item, hasSeen: true})) : []) |
There was a problem hiding this comment.
Fixes accidental cache write using an empty value
| const {isPending, data: broadcasts = []} = useFetchBroadcasts(); | ||
|
|
||
| useEffect(() => { | ||
| if (unseenPostIds.length === 0) { |
There was a problem hiding this comment.
prevent post calls when all posts have been seen
Pass ?limit=3 to the org broadcasts endpoint so the server guarantees at least 3 results, backfilling with other active broadcasts when needed. Removes the client-side assumption that the server always returns enough broadcasts, and updates test mocks to match the new query param. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
@cursoragent update this PR to use the show="latest" and limit=3 as the query param options. The relevant backend changes can be observed in #110323 |
SummaryI've successfully updated this PR to use the new query parameters Changes Made:
These changes align with the backend PR #110323, which adds support for the |
- Add show='latest' query parameter to fetch only active broadcasts - Add limit='3' to explicitly limit results to 3 broadcasts - Update all test mocks to match the new query parameters - Fixes type mismatch in mock query matching by using string values Co-authored-by: Jonas <JonasBa@users.noreply.github.com>


Add test coverage to whats new button and move the fetch handler to the parent component. This is in preparation to making the change to broadcasts so that the endpoint always returns the last 3 broadcasts, regardless if they were seen or not which will prevent the empty state from being shown (poor ux given the importance of the primary sidebar button)
Requires #110286