diff --git a/client/src/components/browser.rs b/client/src/components/browser.rs index e64ebea..ef46a00 100644 --- a/client/src/components/browser.rs +++ b/client/src/components/browser.rs @@ -60,185 +60,187 @@ pub fn Browser() -> impl IntoView { view! {
-

Game Browser

- - - - - - - - - - - {move || { - game_browser_context() - .iter() - .map(|game| { - view! { - - - - - - - + Disconnected.

}> +

Game Browser

+
+
NameHostPlayersCard Packs
{&game.name}{&game.host} - {&game.players.to_string()} - - {&game.packs.len().to_string()} - - - -
+ + + + + + + + + + + + + + + + + } } - }) - .collect_view() - }} - -
NameHostPlayersCard Packs
{&game.name}{&game.host} + {&game.players.to_string()} + + {&game.packs.len().to_string()} + + + +
-
-
- -
-
-

Create Game

- -

Packs

-
- - - - TODO: finish this + /> +
- - -
-

Official

- {move || { - card_packs() - .official_meta - .into_iter() - .map(|n| { - view! { - - - -
- - // hax - {set_selected_packs - .update(|packs| { - packs.insert(n.pack); - })} - } - }) - .collect_view() - }} +
+
+ +

Create Game

+ +

Packs

+
+ + + + TODO: finish this
-
-

Unofficial

- {move || { - card_packs() - .unofficial_meta - .into_iter() - .map(|n| { - view! { - + +
+

Official

+ {move || { + card_packs() + .official_meta + .into_iter() + .map(|n| { + view! { + + + +
+ + // hax + {set_selected_packs + .update(|packs| { + packs.insert(n.pack); + })} } - /> + }) + .collect_view() + }} - -
+
+
+

Unofficial

+ {move || { + card_packs() + .unofficial_meta + .into_iter() + .map(|n| { + view! { + - // hax - {set_selected_packs - .update(|packs| { - packs.insert(n.pack); - })} - } - }) - .collect_view() - }} + +
-
-
- + // hax + {set_selected_packs + .update(|packs| { + packs.insert(n.pack); + })} + } + }) + .collect_view() + }} - - +
+ + + + + +
+
} } diff --git a/client/src/components/websocket.rs b/client/src/components/websocket.rs index 46771f6..6a52f6e 100644 --- a/client/src/components/websocket.rs +++ b/client/src/components/websocket.rs @@ -54,9 +54,10 @@ pub fn Websocket() -> impl IntoView { Rc::new(close.clone()), )); - // TODO: This context stuff can probably be done better + let connected = move || ready_state.get() == ConnectionReadyState::Open; // Contexts for message handler + // TODO: This context stuff can probably be done better let (state_summary, set_state_summary) = create_signal::>(Option::None); let (active_games, set_active_games) = create_signal::>(vec![]); @@ -70,6 +71,17 @@ pub fn Websocket() -> impl IntoView { unofficial_meta: vec![], }); + create_effect(move |_| { + if !connected() { + set_active_games.set_untracked(vec![]); + set_user_update.set_untracked(None); + set_chat_update.set_untracked(None); + set_judge_round.set_untracked(None); + set_chat_message.set_untracked(None); + set_current_game.set_untracked(None); + } + }); + provide_context::>(card_packs_meta); provide_context::>>(user_update); provide_context::>>(chat_update);