diff --git a/internal/webserver/handler_messages.go b/internal/webserver/handler_messages.go index aef3cbf..b45674b 100644 --- a/internal/webserver/handler_messages.go +++ b/internal/webserver/handler_messages.go @@ -1,6 +1,8 @@ package webserver import ( + "encoding/json" + "io" "net/http" "strings" @@ -34,10 +36,24 @@ func (app *Application) Messages(w http.ResponseWriter, r *http.Request) { return } + parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/") + room_id := scraper.DMChatRoomID(parts[0]) + if len(parts) == 2 && parts[1] == "send" { + body, err := io.ReadAll(r.Body) + panic_if(err) + var message_data struct { + Text string `json:"text"` + } + panic_if(json.Unmarshal(body, &message_data)) + trove := scraper.SendDMMessage(room_id, message_data.Text, 0) + app.Profile.SaveDMTrove(trove, false) + go app.Profile.SaveDMTrove(trove, true) + } + chat_view := app.Profile.GetChatRoomsPreview(app.ActiveUser.ID) if strings.Trim(r.URL.Path, "/") != "" { - chat_view.ActiveRoomID = scraper.DMChatRoomID(strings.Trim(r.URL.Path, "/")) - chat_contents := app.Profile.GetChatRoomContents(chat_view.ActiveRoomID) + chat_view.ActiveRoomID = room_id + chat_contents := app.Profile.GetChatRoomContents(room_id) chat_view.MergeWith(chat_contents.DMTrove) chat_view.MessageIDs = chat_contents.MessageIDs } diff --git a/internal/webserver/static/styles.css b/internal/webserver/static/styles.css index 5e06024..6a26390 100644 --- a/internal/webserver/static/styles.css +++ b/internal/webserver/static/styles.css @@ -446,7 +446,6 @@ input[type="submit"] { background-color: var(--color-twitter-blue-light); width: 10em; padding: 1em; - margin-top: 1em; border-radius: 1em; font-size: 1em; cursor: pointer; @@ -684,9 +683,14 @@ ul.space-participants-list li { flex-basis: 0; flex-grow: 7; border-left: 1px solid var(--color-outline-gray); - overflow-y: scroll; padding: 0.5em; box-sizing: border-box; + display: flex; + flex-direction: column; +} +.chats-container #chat-view .chat-messages { + flex-grow: 1; + overflow-y: auto; } .chats-container #chat-view .our-message { align-items: flex-end; @@ -763,5 +767,24 @@ ul.space-participants-list li { } .dm-message-content-container .replying-to-label img.svg-icon { width: 1em; - +} +.dm-composer-container { + padding-top: 0.5em; + border-top: 1px solid var(--color-outline-gray); +/* position: absolute; + bottom: 1em; + right: 0.5em; + left: 0.5em;*/ +} +.dm-composer-container form { + display: flex; +} +span.composer { + flex-grow: 1; + border: 1px solid #ccc; + font-family: inherit; + font-size: inherit; + padding: 1px 6px; + max-height: 10em; + overflow-y: auto; /* scrollbar only if needed */ } diff --git a/internal/webserver/tpl/includes/base.tpl b/internal/webserver/tpl/includes/base.tpl index 69ed62f..be7e25f 100644 --- a/internal/webserver/tpl/includes/base.tpl +++ b/internal/webserver/tpl/includes/base.tpl @@ -8,6 +8,7 @@ +