fix game swap card mismatch

This commit is contained in:
Adam 2024-08-18 20:19:32 -04:00
parent 11a694bbac
commit c71e17ff91

View file

@ -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());
});