Closed camdendotlol closed 2 months ago
Name | Link |
---|---|
Latest commit | 0b877d5cf91e97d2ee7a765f91a1f222e44b0d59 |
Latest deploy log | https://app.netlify.com/sites/topsters3/deploys/6649097b99c6d5000820688c |
Deploy Preview | https://deploy-preview-40--topsters3.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Summary
This PR fixes some inefficiencies in the code related to rendering charts and writing to
localStorage
.Chart rendering
renderChart()
calls in places where the chart is also rendered automatically due to thestore.subscribe
callback (should bring a minor increase in chart performance)topster
package already assumes the same set of defaults when the checked attributes are missing (cuts down on memory usage when a chart is loaded as we were cloning the entire chart to run the migration)localStorage
from the code that reads fromlocalStorage
LocalStorageWatcher
renderless component at the top of the DOM intended be the only component that writes/reads directly to/fromlocalStorage
localStorage
and the Vuex state - this should make the data flow more coherent:LocalStorageWatcher
watches the Vuex state and updateslocalStorage
when it changeslocalStorage
, data flows only one way:Vuex -> localStorage
. An update tolocalStorage
should never trigger a re-render.TopBar
andSwitcher
still communicate withlocalStorage
because they interact with thecurrentlyActive
localStorage
item. It might be worth creating a new state item to track this value so we can give it the same one-way treatment as above.Interaction Layer
Additionally, this PR splits the
ChartCanvas
component into two as suggested by #13:ChartCanvas
contains the canonical rendered chart (plus empty item placeholders) and only re-renders when the chart state changes.InteractionCanvas
handles the drag-and-drop interactivity. This canvas is set to the same size as theChartCanvas
and sits on top of it, but the only thing it ever renders is when the user is dragging an item around on the chart.This system nearly eliminates the jankiness that could occur when moving around items on a large chart on a slower device, as we're not re-rendering everything on the chart for every frame of movement.
Notes
It's possible that the
localStorage
refactor will unblock #36.