chromaui / addon-visual-tests

Visual Tests addon for Storybook
MIT License
31 stars 2 forks source link

Replace `useAddonState` hook implementation to fix state sync bug #133

Closed ghengeveld closed 10 months ago

ghengeveld commented 10 months ago

Manager <> server state were overriding each other, leading to the "run build" button to be stuck in "running" mode when refreshing the browser after running a build that broke.

I've reimplemented the shared state management tool as well as it's server API and manager hook. Besides cleaning things up, the main difference is that it now tracks an index property along with every state update, that will cause a state update to be rejected if the new index isn't higher than the current one. This way any race conditions will not cause weird behavior.

📦 Published PR as canary version: 0.0.109--canary.133.29bf9a1.0
:sparkles: Test out this PR locally via: ```bash npm install @chromaui/addon-visual-tests@0.0.109--canary.133.29bf9a1.0 # or yarn add @chromaui/addon-visual-tests@0.0.109--canary.133.29bf9a1.0 ```
ghengeveld commented 10 months ago

Thanks, I'm glad you like it.

Initially I had a different implementation in mind which is why I started a new SharedState concept rather than updating the original, but in the end I settled on basically the same behavior with the additional of the index. So yeah it's basically the same except for that index and the static constructor.

I think we may want to rename the hook to useSharedState. WDYT?

tmeasday commented 10 months ago

WFM