Skip to main content

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

  1. Open a post whose newest share is a plain repost, ⋯ menu → View shares: the shares are listed.
  2. 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}/shares returns the newest share's own id as firstPostId when that share is a plain repost.
  • [ ] Calling it again with that firstPostId returns 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() returns firstPostId from $posts[0]['data']['id']. Use $posts[0]['repostedDataId'] ?? $posts[0]['data']['id'], as FeedController::feed() and FeedController::entityFeed() do.
  • src/Repository/Primfeed/PostRepository.php: PostRepository::getPosts() maps a plain repost to data = the quoted (original) post and repostedDataId = the repost's own id, and filters on p.createdAt <= firstPost.createdAt. No change needed there.
  • assets/features/primfeed/queries/useShares.tsx: useShares() re-sends the cached first page's firstPostId on every page-1 fetch, and getNextPageParam passes lastPage.posts[0].repostedDataId. Drop the cached pin for page 1 (a reopened dialog should start fresh) and pass lastPage.firstPostId for later pages, as useFeed() does.
  • assets/features/primfeed/components/post/ListSharesPost.tsx: ListSharesPost enables the query only while the dialog is open, which triggers the refetch on reopen. No change expected.

Out of scope

  • feedLiked(), feedBookmarks() and discoveryFeed() also pin on data.id. Not checked whether their first item can be a plain repost.
  • 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".

+++

Status: Completed

Log in to comment and vote

No comments yet

Be the first to share your thoughts.