diff --git a/client/src/components/game.rs b/client/src/components/game.rs index e8b1782..77b3d37 100644 --- a/client/src/components/game.rs +++ b/client/src/components/game.rs @@ -26,6 +26,21 @@ pub fn Game() -> impl IntoView { create_effect(move |_| { if let Some(game) = game_meta() { + // Clear in case of (re-)joining game + set_card_clicked.update(|list| { + list.clear(); + }); + set_selected_cards_ordered.update(|list| { + list.clear(); + }); + set_player_hand.update(|list| { + list.clear(); + }); + set_player_white.update(|list| { + list.clear(); + }); + + // Load meta set_game_id(game.uuid.clone()); set_game_name(game.name.clone()); set_game_host(game.host.clone()); @@ -34,16 +49,11 @@ pub fn Game() -> impl IntoView { set_game_black(game.black.clone()); set_game_white(game.white.clone()); - // Primitive reset when joining new game - set_player_hand(vec![]); - set_selected_cards_ordered(vec![]); - // Load hand for card in game.white { set_player_white.update(|hand| { hand.insert(card.uuid.clone(), card.clone()); }); - set_player_hand.update(|hand| { hand.push(card.uuid.clone()); });