1
0
Fork 0
forked from OpenNeo/impress
impress/app/javascript/wardrobe-2020/WardrobePage
Emi Matchu 258b360ff2 Oops, fix infinite autosaving loop!
A bit of a hack, because the thing triggering it was also a bit of a
hack? I feel like there's something we gotta do with refactoring how
our multiple concepts of state are managed… but in any case! This seems
to keep basic outfit-loading working, while no longer getting us
trapped in autosave loops!

Here's how I reproduced the bug:
1. Open a saved outfit.
2. Set the browser devtools to apply a latency of 5sec to all requests.
3. Add an item to the outfit, and wait for the autosave to start.
4. While it still says "Saving", remove the item again.
5. Watch how, when the first autosave request comes in, the item is
   re-applied to the outfit, then autosave gets stuck looping forever.

The issue was that, when an outfit finishes saving, the change in
outfit data was triggering this effect in `useOutfitState` that was
*meant* to *initialize* local state from the saved outfit, not to keep
them in sync all the time. (In general, when saved outfit data comes
back from the server, we don't want to use it to "fix" local outfit
state in the case of discrepancies, because the most common source of
discrepancy will be the user having made further changes!)

But anyway, one thing I didn't realize is that we *were* depending on
this hacky hook to do more than I thought: it was responsible for
syncing `id` and `appearanceId` to the local state after saving the
outfit. So, I replaced the `rename` action dispatch here with a new
action that explicitly sets all fields the server is responsible for!
2024-02-25 10:37:08 -08:00
..
support Display alt styles in outfit editor when selected 2024-01-30 07:01:03 -08:00
index.js Set up eslint for wardrobe-2020 2023-11-02 18:11:07 -07:00
Item.js Remove the item page drawer, just link to the item page instead 2023-11-03 16:56:51 -07:00
ItemsAndSearchPanels.js Run Prettier on all wardrobe-2020 JS 2023-10-24 16:45:49 -07:00
ItemsPanel.js Make the "Incompatible" explainer more specific for Alt Styles 2024-02-01 05:43:33 -08:00
LayersInfoModal.js Add outfit layers info modal to download PNGs etc 2023-10-23 19:05:10 -07:00
OutfitControls.js Make species/color picker smaller on small screens, to fit pose picker 2024-02-01 05:31:34 -08:00
OutfitKnownGlitchesBadge.js Don't show a glitch message for Alt Style items being Incompatible 2024-02-01 07:13:04 -08:00
PosePicker.js Make the Alt Styles list less tall on large screens 2024-02-01 07:34:39 -08:00
SearchFooter.js Run Prettier on all wardrobe-2020 JS 2023-10-24 16:45:49 -07:00
SearchPanel.js Set up eslint for wardrobe-2020 2023-11-02 18:11:07 -07:00
SearchToolbar.js Set up eslint for wardrobe-2020 2023-11-02 18:11:07 -07:00
useOutfitSaving.js Oops, fix infinite autosaving loop! 2024-02-25 10:37:08 -08:00
useOutfitState.js Oops, fix infinite autosaving loop! 2024-02-25 10:37:08 -08:00
useSearchResults.js Filter by Alt Style in item search and item appearance API calls 2024-02-01 04:58:30 -08:00
WardrobePageLayout.js Bundle wardrobe-2020 into the app 2023-10-23 19:05:08 -07:00
WardrobePreviewAndControls.js Display alt styles in outfit editor when selected 2024-01-30 07:01:03 -08:00