Rework ChatBot #1

Merged
snxraven merged 7 commits from MiTask/LinkUp-P2P-Chat:main into main 2024-06-08 16:19:09 -04:00
Showing only changes of commit 83f75a4fc8 - Show all commits

6
app.js
View File

@ -250,7 +250,7 @@ function onMessageAdded(from, message, avatar) {
$div.classList.add('message'); $div.classList.add('message');
const $img = document.createElement('img'); const $img = document.createElement('img');
$img.src = avatar || 'https://via.placeholder.com/40'; $img.src = avatar || 'https://via.placeholder.com/40'; // Default to a placeholder image if avatar URL is not provided
$div.appendChild($img); $div.appendChild($img);
const $content = document.createElement('div'); const $content = document.createElement('div');
@ -282,7 +282,9 @@ function truncateHash(hash) {
async function updateIcon(username, avatarBuffer) { async function updateIcon(username, avatarBuffer) {
const userIcon = document.querySelector(`img[src*="${username}.png"]`); const userIcon = document.querySelector(`img[src*="${username}.png"]`);
if (userIcon) { if (userIcon) {
userIcon.src = URL.createObjectURL(new Blob([avatarBuffer])); const servePort = 1337;
const avatarUrl = `http://localhost:${servePort}/icons/${username}.png`;
userIcon.src = avatarUrl;
} }
} }