ronaldossendrijver / treachery.online

treachery.online
10 stars 5 forks source link

Undo button in certain conditions undoes up to the last time something was undone instead of latest #72

Closed Moonlington closed 2 months ago

Moonlington commented 2 months ago

It's happened to me a few times now in multiple games where i keep the undo page open, for example when im teaching the game to friends and I have to undo some beginner mistakes people make.

The bugged behavior is as follows: Lets say it is action 10, friend makes a mistake, so i have to undo back to action 10. I keep the undo window open and we play further, it is now action 30 and someone else makes a mistake that has to be undone. The dropdown box shows the correct action that has to be undone, however internally the undoEventId still has action 10 saved. When i press the button to undo i expect it to go back to action 30, but it goes all the way back to action 10.

Looking at the code the undoEventId only gets set to the latest on OnParametersSet, but never if the undo menu stays open. I think a good alternative would be to get the id straight from the selected item in the dropdown menu instead of binding it to a variable? I'd try to fix it myself and PR it if I understood blazor more and could get this running locally.

ronaldossendrijver commented 2 months ago

Thanks for your careful investigation! You're right indeed and I've prepared a fix to be deployed soon.