This commit is contained in:
maddalax 2024-10-04 11:18:33 -05:00
parent 1e51b6b8e8
commit 697b4c4924

View file

@ -18,7 +18,7 @@ func ChatRoom(ctx *h.RequestContext) *h.Page {
h.Div( h.Div(
h.TriggerChildren(), h.TriggerChildren(),
h.Attribute("sse-connect", fmt.Sprintf("/sse/chat/%s", roomId)), h.Attribute("sse-connect", fmt.Sprintf("/ws/chat/%s", roomId)),
h.HxOnSseOpen( h.HxOnSseOpen(
js.ConsoleLog("Connected to chat room"), js.ConsoleLog("Connected to chat room"),
@ -140,6 +140,10 @@ func MessageInput() *h.Element {
return h.Input("text", return h.Input("text",
h.Id("message-input"), h.Id("message-input"),
h.Required(), h.Required(),
h.Class("p-4 rounded-md border border-slate-200 w-full focus:outline-none focus:ring focus:ring-slate-200"),
h.Name("message"),
h.MaxLength(1000),
h.Placeholder("Type a message..."),
h.HxAfterSseMessage( h.HxAfterSseMessage(
js.SetValue(""), js.SetValue(""),
), ),
@ -152,6 +156,7 @@ func Form() *h.Element {
h.Form( h.Form(
h.NoSwap(), h.NoSwap(),
h.PostPartial(partials.SendMessage), h.PostPartial(partials.SendMessage),
h.Attribute("ws-send", ""),
h.Class("flex flex-grow"), h.Class("flex flex-grow"),
MessageInput(), MessageInput(),
), ),