From d3ae8ad65b770d0774dfffd0d853b15335f73e63 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 4 Jul 2020 07:53:32 -0700 Subject: [PATCH] empathy: Don't force active:true when adding state for a new player This fixes the bug where reloading the interface would cause inactive, grayed-out player names to appear solid instead of grayed out. What I had been thinking when writing this code is that this function would be called only when a new player joins the game, (and by definition, a newly joined player must be active). But this function can also be called when a player reloads their interface, and at that point player-join events are received for all players whether active or not. Meanwhile, the server is now explicitly providing the active bit for players, so we get the right information without doing anything. --- empathy/empathy.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index b58f935..90bf0fd 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -996,13 +996,12 @@ class Game extends React.PureComponent { } set_other_player_info(info) { - const player_object = {...info, active: true}; const other_players_copy = [...this.state.other_players]; const idx = other_players_copy.findIndex(o => o.id === info.id); if (idx >= 0) { - other_players_copy[idx] = player_object; + other_players_copy[idx] = info; } else { - other_players_copy.push(player_object); + other_players_copy.push(info); } this.setState({ other_players: other_players_copy -- 2.43.0