asdkjlfhlaskjdhf

This commit is contained in:
2026-03-11 01:20:31 -04:00
parent 2fea81d46b
commit 3160d96c15
5 changed files with 25 additions and 58 deletions

View File

@@ -1,11 +1,7 @@
// Render module: handles chat UI rendering of messages and notices
// this one sucked.
import { getThreads, getRootIds, getReplyTo, getFocused } from "./data.js";
/**
* Render the chat history and input container into the provided chat element.
* @param {HTMLElement} chatEl - The container element for chat entries.
* @param {HTMLElement} inputContainer - The message input area to append at bottom.
*/
// Render the chat history and input container into the provided chat element.
export function renderChat(chatEl, inputContainer) {
// Clear existing content.
chatEl.innerHTML = "";
@@ -49,7 +45,7 @@ export function renderChat(chatEl, inputContainer) {
const shortTimestamp = `${h}:${m} ${ampm}`;
const tsSpan = `<span class="ts" title="${fullTimestamp}">${shortTimestamp}</span>`;
// Distinguish notice vs normal message.
// Distinguish notices and normal messages.
if (msg.username) {
div.classList.add("msg");
if (getFocused() === id) div.classList.add("focused");
@@ -59,7 +55,7 @@ export function renderChat(chatEl, inputContainer) {
div.innerHTML = `${tsSpan} ${msg.content}`;
}
// Append to chat and render children.
// Append to chat and render the children.
chatEl.appendChild(div);
msg.children.forEach((childId) => renderNode(childId, depth + 1));
}
@@ -91,14 +87,12 @@ export function renderChat(chatEl, inputContainer) {
}
}
// Scroll to bottom.
// Scroll to bottom. Or at least try. Let the browser know that is our
// intention. May or may not actually work.
chatEl.scrollTop = chatEl.scrollHeight;
const input = inputContainer.querySelector("input");
if (input) {
input.focus();
// Ensure inputContainer margin resets if at root.
if (replyTo === null) {
inputContainer.style.marginLeft = "0";
}
if (replyTo === null) inputContainer.style.marginLeft = "0";
}
}