From a9e7636c58fe4db3585f5d5750a6c67b653b812d Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Wed, 28 Aug 2024 00:06:59 -0400 Subject: [PATCH] hide stuff when disconnected --- client/src/components/auth.rs | 40 +++--- client/src/components/browser.rs | 117 ++++++++-------- client/src/components/create_game.rs | 4 +- client/src/components/game.rs | 196 ++++++++++++++------------- 4 files changed, 184 insertions(+), 173 deletions(-) diff --git a/client/src/components/auth.rs b/client/src/components/auth.rs index bcf619c..29d2289 100644 --- a/client/src/components/auth.rs +++ b/client/src/components/auth.rs @@ -47,26 +47,28 @@ pub fn Auth() -> impl IntoView { view! {

Sign in:

-

- "You were already given a random name but if you'd like to change it this is the place. Identities are saved once created so if you leave or get disconnected just enter your old name here to \"log back in\". Please don't steal each other's identities (yes, you can)." -

-
-

Username:

-
- + "Disconnected."

}> +

+ "You were already given a random name but if you'd like to change it this is the place. Identities are saved once created so if you leave or get disconnected just enter your old name here to \"log back in\". Please don't steal each other's identities (yes, you can)." +


- - +

Username:

+
+ +
+ +
+
} } diff --git a/client/src/components/browser.rs b/client/src/components/browser.rs index b365204..ae33049 100644 --- a/client/src/components/browser.rs +++ b/client/src/components/browser.rs @@ -1,5 +1,6 @@ use crate::components::websocket::WebSocketContext; use leptos::*; +use leptos_use::core::ConnectionReadyState; use lib::*; use serde_json::to_string; @@ -7,6 +8,8 @@ use serde_json::to_string; pub fn Browser() -> impl IntoView { // Websocket stuff let websocket = expect_context::(); + let connected = move || websocket.ready_state.get() == ConnectionReadyState::Open; + let tx = websocket.clone(); let (websocket_send, set_websocket_send) = create_signal("".to_string()); @@ -37,62 +40,66 @@ pub fn Browser() -> impl IntoView { view! {

Game Browser

-

"Yes, the delete button works. Please don't abuse it."

- 0 } - fallback=|| view! { "No games to show right now.. Maybe you should create one!" } - > -
- - - - - - - - - - - - - - - - - + "Disconnected."

}> + 0 } + fallback=|| { + view! { "No games to show right now.. Maybe you should create one!" } + } + > +

"Yes, the delete button works. Please don't abuse it."

+
+
NameHostPlayersCard Packs
{&game.name}{&game.host} - {&game.players.to_string()} - - {&game.packs.len().to_string()} - - - -
+ + + + + + + + + + + + + + + + + } } - } - /> -
NameHostPlayersCard Packs
{&game.name}{&game.host} + {&game.players.to_string()} + + {&game.packs.len().to_string()} + + + +
-
+ /> + +
+ } diff --git a/client/src/components/create_game.rs b/client/src/components/create_game.rs index 0818023..df48ec5 100644 --- a/client/src/components/create_game.rs +++ b/client/src/components/create_game.rs @@ -62,10 +62,10 @@ pub fn CreateGame() -> impl IntoView { view! {
- Disconnected.

}> +

Create Game

+ "Disconnected."

}>
-

Create Game

impl IntoView { view! {

Game

- -
- + "Disconnected."

}> + +
+ - // Judging view // + // Judging view // - -
- + +
+ + + // Selected cards + } + } + /> +
+ + // Submit button +
+ +
- // Selected cards } - } - /> -
- - // Submit button -
- -
- - - - -
- } - } - /> -
- } - } - /> - - - // Playing view // - - - - // Play cards -
- - - // Selected cards - } - } - /> -
- - // Submit button -
- -
- - // Player hand -
- + + + + } } - } - }> - - + /> +
} } /> -
+
+ + // Playing view // + + + + // Play cards +
+ + + // Selected cards + } + } + /> +
+ + // Submit button +
+ +
+ + // Player hand +
+ + + + } + } + /> +
+