fix: show sidebar reads in profile reads tab when main articles array is empty#191
Open
mstrofnone wants to merge 1 commit into
Open
fix: show sidebar reads in profile reads tab when main articles array is empty#191mstrofnone wants to merge 1 commit into
mstrofnone wants to merge 1 commit into
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
ProfileContext, ~line 906): fetches up to 2 articles viafetchMegaFeedand stores them insidebarArticles.notesProfileTabs, ~line 172): fetches articles viagetProfileMegaFeedwhen the Reads tab is clicked, storing them inarticlesThe Reads tab in
ProfileTabs.tsxonly checksprofile.articles.lengthto determine whether to show the empty state message. When the mainarticlesarray 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 thoughsidebarArticles.noteshas the user's reads.Fix
Check
sidebarArticles.notesas a fallback in three places within the Reads tab:articlesandsidebarArticles.notesare emptysidebarArticles.noteswhenarticlesis empty but sidebar data existsThis is a minimal, targeted fix (4 lines changed) that doesn't alter data fetching logic or other tabs.