This commit is contained in:
Raven Scott 2024-06-04 00:33:53 -04:00
parent b62636ed0e
commit 184edb8b44

16
app.js
View File

@ -50,10 +50,12 @@ async function initialize() {
}
const savedUser = localStorage.getItem('currentUser');
const avatarURL = localStorage.getItem('avatarURL');
if (savedUser) {
const user = JSON.parse(savedUser);
userName = user.username;
userAvatar = user.avatar || '';
userAvatar = avatarURL || '';
const setupDiv = document.querySelector('#setup');
if (setupDiv) {
setupDiv.classList.remove('hidden');
@ -235,13 +237,7 @@ function sendMessage(e) {
}
}
function scrollToBottom() {
var container = document.getElementById("messages-container");
container.scrollTop = container.scrollHeight;
}
function onMessageAdded(from, message, avatar) {
const $div = document.createElement('div');
$div.classList.add('message');
@ -260,16 +256,14 @@ function onMessageAdded(from, message, avatar) {
$text.classList.add('message-text');
// Render Markdown content
const md = window.markdownit();
$text.innerHTML = md.render(message);
const markdownContent = marked(message);
$text.innerHTML = markdownContent;
$content.appendChild($header);
$content.appendChild($text);
$div.appendChild($content);
document.querySelector('#messages').appendChild($div);
scrollToBottom();
}
async function updateIcon(username, avatarBuffer) {
// Update the icon in the local HTML if necessary