fix: fix message submission

This commit is contained in:
Andy Burke 2025-09-12 12:06:12 -07:00
parent e52a9e997c
commit 6df0673c8e
3 changed files with 20 additions and 14 deletions

View file

@ -43,9 +43,10 @@
<script>
{
const form = document.currentScript.closest("form");
const file_input = document.querySelector('input[type="file"]');
const chat_input = document.getElementById("topic-chat-input");
const parent_id_input = document.getElementById("parent-id");
const file_input = form.querySelector('input[type="file"]');
const chat_input = form.querySelector('textarea[name="data.content"]');
const parent_id_input = form.querySelector('input[name="parent_id"]');
const topic_chat_container =
document.getElementById("topic-chat-container");
const topic_chat_content =
@ -53,6 +54,13 @@
let messages_in_flight = {};
document.addEventListener(
"topic_changed",
({ detail: { topic_id } }) => {
form.action = topic_id ? `/api/topics/${topic_id}/events` : "";
},
);
chat_input.addEventListener("keypress", (event) => {
if (event.key === "Enter" && !event.shiftKey) {
form.requestSubmit();
@ -100,8 +108,6 @@
if (form.uploaded_urls.length === 0 && message.length === 0) {
return false;
}
form.action = `/api/topics/${topic_id}/events`;
};
form.on_parsed = (json) => {