clean up stuff on disconnect
This commit is contained in:
parent
35afcf7dd4
commit
89344c6042
2 changed files with 185 additions and 171 deletions
|
@ -60,7 +60,9 @@ pub fn Browser() -> impl IntoView {
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="p-1">
|
<div class="p-1">
|
||||||
|
<Show when=move || connected() fallback=|| view! { <p>Disconnected.</p> }>
|
||||||
<h2 class="text-2xl">Game Browser</h2>
|
<h2 class="text-2xl">Game Browser</h2>
|
||||||
|
<div class="p-1">
|
||||||
<table class="min-w-full border border-collapse table-auto">
|
<table class="min-w-full border border-collapse table-auto">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -71,10 +73,10 @@ pub fn Browser() -> impl IntoView {
|
||||||
<th class="border-b"></th>
|
<th class="border-b"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{move || {
|
<For
|
||||||
game_browser_context()
|
each=move || game_browser_context()
|
||||||
.iter()
|
key=|game| game.uuid.clone()
|
||||||
.map(|game| {
|
children=move |game| {
|
||||||
view! {
|
view! {
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center border-b">{&game.name}</td>
|
<td class="text-center border-b">{&game.name}</td>
|
||||||
|
@ -107,10 +109,8 @@ pub fn Browser() -> impl IntoView {
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.collect_view()
|
/>
|
||||||
}}
|
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
@ -240,5 +240,7 @@ pub fn Browser() -> impl IntoView {
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,9 +54,10 @@ pub fn Websocket() -> impl IntoView {
|
||||||
Rc::new(close.clone()),
|
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
|
// Contexts for message handler
|
||||||
|
// TODO: This context stuff can probably be done better
|
||||||
let (state_summary, set_state_summary) =
|
let (state_summary, set_state_summary) =
|
||||||
create_signal::<Option<ServerStateSummary>>(Option::None);
|
create_signal::<Option<ServerStateSummary>>(Option::None);
|
||||||
let (active_games, set_active_games) = create_signal::<Vec<GameBrowserMeta>>(vec![]);
|
let (active_games, set_active_games) = create_signal::<Vec<GameBrowserMeta>>(vec![]);
|
||||||
|
@ -70,6 +71,17 @@ pub fn Websocket() -> impl IntoView {
|
||||||
unofficial_meta: vec![],
|
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::<ReadSignal<CardPacksMeta>>(card_packs_meta);
|
provide_context::<ReadSignal<CardPacksMeta>>(card_packs_meta);
|
||||||
provide_context::<ReadSignal<Option<UserUpdate>>>(user_update);
|
provide_context::<ReadSignal<Option<UserUpdate>>>(user_update);
|
||||||
provide_context::<ReadSignal<Option<ChatUpdate>>>(chat_update);
|
provide_context::<ReadSignal<Option<ChatUpdate>>>(chat_update);
|
||||||
|
|
Loading…
Add table
Reference in a new issue