fix(canvas): restore metrics on page reload and IPFS view#224
fix(canvas): restore metrics on page reload and IPFS view#224tnkshuuhei merged 3 commits intodevfrom
Conversation
…ge read Move loadCanvasState() from useMemo (runs during SSR/hydration) to useEffect (runs after mount) so server and client initial renders produce identical HTML.
cardsToNodes() did not include metrics in node data, causing metric badges to disappear after reload or when viewing IPFS-saved canvases. Merge cardMetrics into node data during initialization and hydration.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Review: fix(canvas): restore metrics on page reload and IPFS viewGood fix overall — the root cause is correctly identified and the solution is sound. A few items worth addressing: Bug: Potential runtime error with legacy localStorage data
metrics: savedState.cardMetrics[node.id],If a user has existing localStorage data saved before metrics: savedState.cardMetrics?.[node.id],Same applies to setCardMetrics(savedState.cardMetrics ?? {});Design concern: Dual source of truth for metricsThis PR now stores metric data in two places simultaneously:
They're initialized together correctly here, but any downstream operation that calls Minor: Brief flash of unsaved state on reloadThe deferred Nit:
|
git log --pretty=format: does not append a trailing newline. When the output is a single line, `while read` sees EOF without a newline and skips the loop body entirely, silently dropping the entry (e.g. PR #224 was missing from the release summary). Switching to tformat: adds a terminating newline after each entry.
Summary
cardsToNodes()did not include metrics innode.data.metrics, so CardNode could not render badges after state restorationcardMetricsinto node data during both initialization and localStorage hydrationRelated Issues
Test plan
bun run buildpasses without errors