Compare commits

..

2 Commits

Author SHA1 Message Date
9f514c31f9 Merge branch 'main' into main 2024-06-08 19:44:21 +00:00
Raven Scott
748f4664b3 Try to fix update icons 2024-06-08 15:40:58 -04:00

8
app.js
View File

@ -68,6 +68,7 @@ async function initialize() {
peerCount++; peerCount++;
updatePeerCount(); updatePeerCount();
// Send the current user's icon to the new peer
const iconBuffer = await drive.get(`/icons/${userName}.png`); const iconBuffer = await drive.get(`/icons/${userName}.png`);
if (iconBuffer) { if (iconBuffer) {
const iconMessage = JSON.stringify({ const iconMessage = JSON.stringify({
@ -280,14 +281,15 @@ function truncateHash(hash) {
} }
async function updateIcon(username, avatarBuffer) { async function updateIcon(username, avatarBuffer) {
// Update the icon in the local HTML if necessary
// This can be adjusted as per your needs
const userIcon = document.querySelector(`img[src*="${username}.png"]`); const userIcon = document.querySelector(`img[src*="${username}.png"]`);
if (userIcon) { if (userIcon) {
const servePort = 1337; userIcon.src = URL.createObjectURL(new Blob([avatarBuffer]));
const avatarUrl = `http://localhost:${servePort}/icons/${username}.png`;
userIcon.src = avatarUrl;
} }
} }
function clearMessages() { function clearMessages() {
const messagesContainer = document.querySelector('#messages'); const messagesContainer = document.querySelector('#messages');
while (messagesContainer.firstChild) { while (messagesContainer.firstChild) {