pokemonAutoChess
pokemonAutoChess copied to clipboard
Improve preparation room leave callbacks
Several changes aiming to close properly the connections to the rooms, especially the preparation room:
- in Network store, replace room.connection.close() with room.leave(true) ; this enables calling the onLeave callbacks which removes the reconnection tokens properly ; this also remove immediately the client without waiting the allowed reconnection delay.
- navigate to lobby if loading the preparation room without a valid reconnection token for a preparation room
- remove preparation room reconnection token if room is left with another close code than anormal closure / timeout
- use useCallback to memo large functions in preparation room to increase performance
I hope these would help to avoid the "lobby mislaunch" bug and the "lost elo for a game i not played" reports. I believe most of these reports is from people leaving the preparation screen without using the leave button (probably browser back button), and therefore still having the allowed reconnection time active, and the game being launched at that moment. Now they are immediately removed if they leave preparation room.