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.