Compare commits

..

No commits in common. "e33244c1f12adf68274ea6ef023a22e2ad4ca82d" and "9f514c31f96cc3b4a855ad5c905edab560e32f7e" have entirely different histories.

9
app.js
View File

@ -67,7 +67,6 @@ 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`);
@ -95,7 +94,6 @@ async function initialize() {
connection.on('close', () => {
peerCount--;
updatePeerCount();
console.log('Peer disconnected, current peer count:', peerCount);
});
});
@ -123,7 +121,7 @@ function registerUser(e) {
reader.onload = (event) => {
const buffer = new Uint8Array(event.target.result);
drive.put(`/icons/${regUsername}.png`, buffer);
userAvatar = `http://localhost:1337/icons/${regUsername}.png`; // Set the correct URL
userAvatar = URL.createObjectURL(new Blob([buffer]));
registeredUsers[regUsername] = userAvatar;
localStorage.setItem('registeredUsers', JSON.stringify(registeredUsers));
continueRegistration(regUsername);
@ -287,10 +285,11 @@ 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 = `http://localhost:1337/icons/${username}.png`; // Ensure the URL is correct
userIcon.src = URL.createObjectURL(new Blob([avatarBuffer]));
}
}
function clearMessages() {
const messagesContainer = document.querySelector('#messages');
while (messagesContainer.firstChild) {
@ -303,4 +302,4 @@ function toggleSetupView() {
setupDiv.classList.toggle('hidden');
}
initialize();
initialize();