Dashboard post-merge fixes: counter, ex-div day, dividend mini#174
Merged
Conversation
Two bugs reported from a populated prod account: **Counters stuck at 0.** `useCountUp` only animated on the first visibility intersect; when the data hooks loaded async (target flipping 0 → N a tick later), the re-run of the effect saw `startedRef.current = true` and skipped. Rewrote the hook so it animates from the *previous* value to the new target on every target change, with visibility tracked once but not gating subsequent updates. Reduced-motion still short-circuits to the final value immediately. **"SBUX in 5d" vs "in 4d" mismatch.** DashboardGreeting used `Math.ceil` while UpcomingExDividends uses `Math.round`. Server ships date-only strings (parsed as UTC midnight) and we compare against local midnight — for UTC+N users that's a fractional diff (e.g. 4.08 days), and ceil produces 5 while round produces 4. Aligned Greeting to `round` so both surfaces agree. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
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.
Three bugs reported in prod after #173 merged.
1. Quick-stat counters stuck at 0
AnimatedCounter(inDashboardGreeting) rendered 0 holdings / 0 on radar even when the user had data.Root cause.
useCountUponly animated on the first viewport intersect. Sequence on a real account:useHoldings()loading →holdings.length === 0→ target = 0.startedRef.current = true→ animate 0 → 0.holdings.length === N→ effect re-runs with new target.startedRef.current === true→ skips → counter sticks at 0.Fix. Rewrote
useCountUpso it animates from the previous value to the new target on every change, with visibility tracked separately (once) but not gating subsequent updates. Reduced-motion still short-circuits.2. "SBUX in 5d" greeting vs "in 4d" in upcoming list
DashboardGreetingandUpcomingExDividendsdisagreed by 1 day for the same stock.Root cause.
GreetingusedMath.ceil,UpcomingExDividendsusesMath.round. Server ships date-only strings (parsed as UTC midnight); compared against local midnight, that's a fractional diff (e.g. 4.08 days). ceil → 5, round → 4.Fix. One-line change in
Greetingto useMath.round.3. DividendIncomeMini hidden despite recorded dividends
User had several dividends, mini didn't render.
Root cause.
/dividends/chart_datareturns 24 buckets per currency: 12 past + 12 future. Past months carryactual(paid), future ones carryprojected. Myslice(-12)grabbed the last 12 (= current month + 11 future), whereactualis mostly null — so the "sum of actual values" sat at 0 unless the current month had a payment, and the card hid itself.Fix. Filter to past-only entries (
actual !== null) and take the last 12 of those. Robust to wider server windows (range=full).Test plan
npx tsc --noEmit— clean🤖 Generated with Claude Code