diff --git a/apis/src/components/molecules/control_buttons.rs b/apis/src/components/molecules/control_buttons.rs index beb1b2e3..0e6890ff 100644 --- a/apis/src/components/molecules/control_buttons.rs +++ b/apis/src/components/molecules/control_buttons.rs @@ -21,13 +21,12 @@ pub fn ControlButtons() -> impl IntoView { .expect("Control buttons show only for logged in players") }; - let color = move || { + let color = Signal::derive(move || { game_state - .signal - .get_untracked() - .user_color(user_id()) - .expect("Control buttons show only for logged in players") - }; + .user_color_as_signal(Some(user_id()).into()) + .get() + .expect("User_id is one of the players in this game") + }); let pending = create_read_slice(game_state.signal, |gs| gs.game_control_pending.clone()); let not_tournament = create_read_slice(game_state.signal, |gs| { gs.game_response diff --git a/apis/src/providers/game_state.rs b/apis/src/providers/game_state.rs index 1c3fd5e0..a5ac6c57 100644 --- a/apis/src/providers/game_state.rs +++ b/apis/src/providers/game_state.rs @@ -300,7 +300,7 @@ impl GameState { } // Still needed because send_game_control uses it, maybe this should be moved out of the gamestate? - pub fn user_color(&self, user_id: Uuid) -> Option { + fn user_color(&self, user_id: Uuid) -> Option { if Some(user_id) == self.black_id { return Some(Color::Black); } @@ -327,7 +327,7 @@ impl GameState { pub fn send_game_control(&mut self, game_control: GameControl, user_id: Uuid) { if let Some(color) = self.user_color(user_id) { if color != game_control.color() { - log!("This is a bug, you should only send GCs of your own color"); + log!("This is a bug, you should only send GCs of your own color, user id color is {color} and gc color is {}", game_control.color()); } else if let Some(ref game_id) = self.game_id { ApiRequests::new().game_control(game_id.to_owned(), game_control); } else {