Keep the shares list when the View shares dialog is reopened
Context
On a post that has been shared, "View shares" lists who shared it. Close the dialog and open it again, and the list comes back empty, so residents can't see the shares a second time without reloading the page.
Goal
The shares dialog lists the post's shares every time it's opened.
+++ For the agent
Task
Fix the pagination pin of the shares list. GET /pf/{post}/shares sets firstPostId from posts[0].data.id, but for a plain repost (no text) data is the original post, so the pin is the original post, older than every share. The cached query sends that pin back when the dialog reopens and the query returns nothing. Pin on the share itself, as the other feeds do, and make useShares take its later-page pin from the first page instead of from the previous page's top post.
Current behavior
- Open a post whose newest share is a plain repost, ⋯ menu → View shares: the shares are listed.
- Close the dialog, open it again: the list is empty.
The reopen refetches page 1 with the cached firstPostId (the original post's id), so PostRepository::getPosts() keeps only shares with createdAt <= the original post's: none. Separately, getNextPageParam pins page N+1 on page N's top share, so from page 3 on the window moves and shares get skipped.
Expected behavior
Reopening the dialog lists the shares again, including any made since it was first opened. Infinite scroll lists every share once, in order.
Acceptance criteria
- [ ]
GET /pf/{post}/sharesreturns the newest share's own id asfirstPostIdwhen that share is a plain repost. - [ ] Calling it again with that
firstPostIdreturns the same shares (PHP test). - [ ] Opening, closing and reopening View shares lists the shares both times.
- [ ] Pages 2+ reuse the first page's
firstPostId.
Where it lives
src/Controller/PrivateApi/Primfeed/FeedController.php:FeedController::postShares()returnsfirstPostIdfrom$posts[0]['data']['id']. Use$posts[0]['repostedDataId'] ?? $posts[0]['data']['id'], asFeedController::feed()andFeedController::entityFeed()do.src/Repository/Primfeed/PostRepository.php:PostRepository::getPosts()maps a plain repost todata= the quoted (original) post andrepostedDataId= the repost's own id, and filters onp.createdAt <= firstPost.createdAt. No change needed there.assets/features/primfeed/queries/useShares.tsx:useShares()re-sends the cached first page'sfirstPostIdon every page-1 fetch, andgetNextPageParampasseslastPage.posts[0].repostedDataId. Drop the cached pin for page 1 (a reopened dialog should start fresh) and passlastPage.firstPostIdfor later pages, asuseFeed()does.assets/features/primfeed/components/post/ListSharesPost.tsx:ListSharesPostenables the query only while the dialog is open, which triggers the refetch on reopen. No change expected.
Out of scope
feedLiked(),feedBookmarks()anddiscoveryFeed()also pin ondata.id. Not checked whether their first item can be a plain repost.
Related
- FEED-1392: earlier fix in the same dialog (clicking outside the shares list crashed the page).
The original request is in the comment "Original description, before cleanup".
+++
Log in to comment and vote
No comments yet
Be the first to share your thoughts.