chatroom name

This commit is contained in:
Adam 2024-07-29 00:53:42 -04:00
parent f5ee3357a5
commit a3fef2d069

View file

@ -14,6 +14,7 @@ pub fn Chat() -> impl IntoView {
// Chat stuff
let (chat_history, set_chat_history) = create_signal::<Vec<String>>(vec![]);
let (users, set_users) = create_signal::<Vec<String>>(vec![]);
let (chat_name, set_chat_name) = create_signal::<String>("".to_string());
let chat_history_ref = create_node_ref::<Textarea>();
let chat_input_ref = create_node_ref::<Input>();
@ -56,6 +57,7 @@ pub fn Chat() -> impl IntoView {
chat_update_context.with(move |chat_update| {
if let Some(update) = chat_update {
set_users(update.users.clone());
set_chat_name(update.room.clone());
}
})
});
@ -93,7 +95,7 @@ pub fn Chat() -> impl IntoView {
view! {
<div class="p-1">
<h2 class="text-2xl">Chat:</h2>
<h2 class="text-2xl">Chat: {move || chat_name()}</h2>
<span class="flex">
<textarea
node_ref=chat_history_ref
@ -104,7 +106,7 @@ pub fn Chat() -> impl IntoView {
{move || chat_history.get()}
</textarea>
<ul>
<h2 class="text-2xl">Users:</h2>
<h2 class="text-2xl">Users: {move || users().len()}</h2>
{move || users().into_iter().map(|n| view! { <li>{n}</li> }).collect_view()}
</ul>
</span>