fix(ui): hide awkward empty state for weekly downloads for new packages#1054
fix(ui): hide awkward empty state for weekly downloads for new packages#1054serhalp merged 4 commits intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
📝 WalkthroughWalkthroughThe WeeklyDownloadStats component now tracks loading and data presence with two new state properties. Rendering is conditional: a sparkline or loading skeleton shows only while loading or when data exists; an explicit "No download data available" message appears for empty data. The chart modal and analyse button are prevented from opening/displaying when no weekly-download data exists. Unit tests cover both empty and populated scenarios. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR fixes the awkward empty state for weekly downloads on new packages by conditionally hiding the entire downloads section when no data is available. The implementation adds loading state tracking and data presence checks to determine when to show or hide the section, following the pattern used by npmjs.com.
Changes:
- Added computed property to check if weekly downloads data exists
- Added loading state to track data fetch progress
- Conditionally render the downloads section based on loading state or data presence
- Guard modal opening and button visibility with data presence checks
|
My hunch is it's more confusing to hide this entirely. We might get future bug reports like "the downloads chart is missing". Could we keep just the heading and show "No downloads yet"? 🤔 |
Good idea, I'll do this today |
| <!-- Data label (covers ~42% width) --> | ||
| <div class="w-[42%] flex items-center ps-0.5"> | ||
| <SkeletonInline class="h-7 w-24" /> | ||
| <template v-if="isLoadingWeeklyDownloads || hasWeeklyDownloads"> |
There was a problem hiding this comment.
does this mean if we're loading the downloads but ultimately have none in the end, we'll flash the chart up then remove it?
There was a problem hiding this comment.
I guess we're optimistically assuming it WILL load, as it does for 99,9% of cases
|
also agree we should show a "no data" message or something instead, like a subtle overlay of some sort i see you're already planning on changing it so will re-review once you push 👍 |
|
(marked as draft while you're making changes) |
87fbffd to
e4a5623
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/components/Package/WeeklyDownloadStats.vue (1)
104-119:⚠️ Potential issue | 🟠 MajorReset weekly download state before fetching to avoid stale charts and surprise modal re-open.
When switching packages, the previous
weeklyDownloadsarray remains until the new request resolves, so the sparkline/analyse button can briefly show old data. If the modal was open,isChartModalOpencan also stay true and re-open when data returns. Clearing the data and resetting modal state at the start of each load prevents that.💡 Proposed fix
async function loadWeeklyDownloads() { if (!import.meta.client) return isLoadingWeeklyDownloads.value = true + weeklyDownloads.value = [] + if (isChartModalOpen.value) { + isChartModalOpen.value = false + hasChartModalTransitioned.value = false + } try { const result = await fetchPackageDownloadEvolution( () => props.packageName, () => props.createdIso, () => ({ granularity: 'week' as const, weeks: 52 }), )
Closes #1044
Too new packages now have Weekly downloads hidden:
Well established packages of course still have the section: