discourse/plugins/discourse-reactions/test
small-lovely-cat 48e7df1b35
FIX: discourse-reactions rollback not working (#36989)
The discourse-reactions plugin has a rollback function, when the
`toggle.json` request fails, the page should rollback the reactions to
the original state.

However, the function is broken, and the original `_rollbackState()`
function never works as the state itself changes when `toggleReaction`
is called. And the reaction state never goes back without
refreshing/reloading the window, leading to the heart/reactions leaving
on the page even when the request failed.

This commit fixs this by adding a new function `_captureState()`,
keeping the state in a const value, and revert it to the page data when
necessary.

Also, a spec for this is added to prevent regression.
2026-01-08 14:23:59 +10:00
..
javascripts FIX: discourse-reactions rollback not working (#36989) 2026-01-08 14:23:59 +10:00