From 8c54e4ca77fb6310e6555ee0d3c82e862ca60b93 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sat, 8 Jun 2024 15:48:56 -0400 Subject: [PATCH 1/2] Try to fix update icons --- app.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 3c8ed9c..e872a12 100644 --- a/app.js +++ b/app.js @@ -121,7 +121,7 @@ function registerUser(e) { reader.onload = (event) => { const buffer = new Uint8Array(event.target.result); drive.put(`/icons/${regUsername}.png`, buffer); - userAvatar = URL.createObjectURL(new Blob([buffer])); + userAvatar = `http://localhost:1337/icons/${regUsername}.png`; // Set the correct URL registeredUsers[regUsername] = userAvatar; localStorage.setItem('registeredUsers', JSON.stringify(registeredUsers)); continueRegistration(regUsername); @@ -285,11 +285,10 @@ async function updateIcon(username, avatarBuffer) { // This can be adjusted as per your needs const userIcon = document.querySelector(`img[src*="${username}.png"]`); if (userIcon) { - userIcon.src = URL.createObjectURL(new Blob([avatarBuffer])); + userIcon.src = `http://localhost:1337/icons/${username}.png`; // Ensure the URL is correct } } - function clearMessages() { const messagesContainer = document.querySelector('#messages'); while (messagesContainer.firstChild) { From ac2da1524df9869f50c75233a7052321f0c64633 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sat, 8 Jun 2024 15:52:44 -0400 Subject: [PATCH 2/2] Trying to fix peer counts --- app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index e872a12..30eea35 100644 --- a/app.js +++ b/app.js @@ -67,6 +67,7 @@ async function initialize() { swarm.on('connection', async (connection, info) => { peerCount++; updatePeerCount(); + console.log('Peer connected, current peer count:', peerCount); // Send the current user's icon to the new peer const iconBuffer = await drive.get(`/icons/${userName}.png`); @@ -94,6 +95,7 @@ async function initialize() { connection.on('close', () => { peerCount--; updatePeerCount(); + console.log('Peer disconnected, current peer count:', peerCount); }); }); @@ -301,4 +303,4 @@ function toggleSetupView() { setupDiv.classList.toggle('hidden'); } -initialize(); \ No newline at end of file +initialize();