Skip to content

fix: show sidebar reads in profile reads tab when main articles array is empty#191

Open
mstrofnone wants to merge 1 commit into
PrimalHQ:mainfrom
mstrofnone:fix/profile-reads-empty-state
Open

fix: show sidebar reads in profile reads tab when main articles array is empty#191
mstrofnone wants to merge 1 commit into
PrimalHQ:mainfrom
mstrofnone:fix/profile-reads-empty-state

Conversation

@mstrofnone
Copy link
Copy Markdown

Problem

When visiting a profile that has published reads (long-form notes), the profile stats correctly show e.g. "2 reads", but clicking the Reads tab displays "${name} hasn't published any reads".

Reproduce: Visit https://primal.net/p/nprofile1qqsyxxz7mm9kwkyjsf935da90ulyqlaautk6wgq68q5m3n6t5lzmfuqur0zgt — the profile shows 2 reads, but clicking the Reads tab shows "mstrofnone hasn't published any reads".

Root Cause

The profile page makes two separate fetches for reads:

  1. Sidebar fetch (ProfileContext, ~line 906): fetches up to 2 articles via fetchMegaFeed and stores them in sidebarArticles.notes
  2. Tab fetch (ProfileTabs, ~line 172): fetches articles via getProfileMegaFeed when the Reads tab is clicked, storing them in articles

The Reads tab in ProfileTabs.tsx only checks profile.articles.length to determine whether to show the empty state message. When the main articles array is empty (either because the tab hasn't been clicked yet, or the mega feed request returned empty), it shows the "hasn't published any reads" message — even though sidebarArticles.notes has the user's reads.

Fix

Check sidebarArticles.notes as a fallback in three places within the Reads tab:

  1. Skeleton loader: only show loading skeletons when both articles and sidebarArticles.notes are empty
  2. Empty state message: only show "hasn't published any reads" when both arrays are empty
  3. Article list: show articles from sidebarArticles.notes when articles is empty but sidebar data exists

This is a minimal, targeted fix (4 lines changed) that doesn't alter data fetching logic or other tabs.

… is empty

When a profile has published reads (long-form notes), the sidebar
fetches up to 2 articles and stores them in sidebarArticles.notes.
However, the reads tab only checks profile.articles (populated on
tab click) to decide whether to show the 'hasn't published any reads'
empty state message.

This causes a bug where the profile stats show e.g. '2 reads' but
clicking the reads tab shows 'hasn't published any reads' because
the main articles array hasn't been populated yet or the mega feed
request returned empty results.

Fix: also check sidebarArticles.notes when determining whether to
show the empty state, skeleton loaders, or article list. When the
main articles array is empty but sidebar articles exist, fall back
to displaying the sidebar articles.
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