Compare commits
No commits in common. "0bf9a626362301e8cc6773615402a4302939e492" and "a54c56331dbca221cb03e78d0377b06b2d957f33" have entirely different histories.
0bf9a62636
...
a54c56331d
2 changed files with 1 additions and 26 deletions
|
@ -1,25 +1,9 @@
|
||||||
use crate::components::websocket::WebSocketContext;
|
|
||||||
use html::Input;
|
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use lib::models::*;
|
|
||||||
use serde_json::to_string;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Auth() -> impl IntoView {
|
pub fn Auth() -> impl IntoView {
|
||||||
let websocket = expect_context::<WebSocketContext>();
|
|
||||||
let (username, _set_username) = create_signal("Anonymous");
|
let (username, _set_username) = create_signal("Anonymous");
|
||||||
|
|
||||||
let username_input_ref = create_node_ref::<Input>();
|
|
||||||
let send_login = move |_| {
|
|
||||||
websocket.send(
|
|
||||||
&to_string(&UserLogIn {
|
|
||||||
username: username_input_ref.get().unwrap().value(),
|
|
||||||
})
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
logging::log!("sent");
|
|
||||||
};
|
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="p-1">
|
<div class="p-1">
|
||||||
<h2 class="text-2xl">Sign in:</h2>
|
<h2 class="text-2xl">Sign in:</h2>
|
||||||
|
@ -27,14 +11,6 @@ pub fn Auth() -> impl IntoView {
|
||||||
<input
|
<input
|
||||||
class="w-96 font-mono rounded-sm bg-slate-900 text-slate-200"
|
class="w-96 font-mono rounded-sm bg-slate-900 text-slate-200"
|
||||||
placeholder=move || username.get()
|
placeholder=move || username.get()
|
||||||
node_ref=username_input_ref
|
|
||||||
on:change=send_login.clone()
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
class="py-2 px-4 pl-4 font-bold text-white rounded border-b-4 bg-slate-600 border-slate-800 hover:bg-slate-700 hover:border-slate-500"
|
|
||||||
type="submit"
|
|
||||||
value="Send"
|
|
||||||
on:change=send_login.clone()
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ use html::{Input, Textarea};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_use::core::ConnectionReadyState;
|
use leptos_use::core::ConnectionReadyState;
|
||||||
use lib::models::*;
|
use lib::models::*;
|
||||||
use serde_json::to_string;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Chat() -> impl IntoView {
|
pub fn Chat() -> impl IntoView {
|
||||||
|
@ -52,7 +51,7 @@ pub fn Chat() -> impl IntoView {
|
||||||
// Handle sending messages
|
// Handle sending messages
|
||||||
let send_message = move |_| {
|
let send_message = move |_| {
|
||||||
websocket.send(
|
websocket.send(
|
||||||
&to_string(&ChatMessage {
|
&serde_json::to_string(&ChatMessage {
|
||||||
text: chat_input_ref.get().unwrap().value(),
|
text: chat_input_ref.get().unwrap().value(),
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue