From a79195d1406a512af7f8a7ce3d515eef0cd45152 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sun, 9 Jun 2024 03:34:27 -0400 Subject: [PATCH] Revert "Bug Fix: Update HTTP Port for icon on launch, remove timebased stoage directory for single user usage" This reverts commit 3d0c10db2b40ccd02adaee5de644051161e17c71. --- app.js | 16 ++-------------- config.json | 1 - 2 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 config.json diff --git a/app.js b/app.js index 61830ed..8ceceb6 100644 --- a/app.js +++ b/app.js @@ -7,7 +7,7 @@ import Corestore from 'corestore'; import { EventEmitter } from 'events'; import fs from "fs"; -const storagePath = `./storage/`; +const storagePath = `./storage/storage_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`; const store = new Corestore(storagePath); const drive = new Hyperdrive(store); @@ -99,14 +99,9 @@ async function initialize() { if (configExists) { config = JSON.parse(fs.readFileSync("./config.json", 'utf8')); console.log("Read config from file:", config) - // Update port in URLs - config.userAvatar = updatePortInUrl(config.userAvatar); config.rooms.forEach(room => { addRoomToListWithoutWritingToConfig(room); }); - for (let user in registeredUsers) { - registeredUsers[user] = updatePortInUrl(registeredUsers[user]); - } } const registerDiv = document.querySelector('#register'); @@ -180,7 +175,7 @@ function registerUser(e) { const buffer = new Uint8Array(event.target.result); await drive.put(`/icons/${regUsername}.png`, buffer); config.userAvatar = `http://localhost:${servePort}/icons/${regUsername}.png`; // Set the correct URL - registeredUsers[regUsername] = `http://localhost:${servePort}/icons/${regUsername}.png`; // Use placeholder URL + registeredUsers[regUsername] = config.userAvatar; localStorage.setItem('registeredUsers', JSON.stringify(registeredUsers)); continueRegistration(regUsername); }; @@ -443,11 +438,4 @@ function writeConfigToFile(filePath) { }); } -function updatePortInUrl(url) { - if (!url) return url; - const urlObject = new URL(url); - urlObject.port = servePort; - return urlObject.toString(); -} - initialize(); diff --git a/config.json b/config.json deleted file mode 100644 index 1da36b0..0000000 --- a/config.json +++ /dev/null @@ -1 +0,0 @@ -{"userName":"Raven2","userAvatar":"http://localhost:59080/icons/Raven2.png","rooms":["9c2dd1bb04533761a18508e558616d9c4add62ebbce59632eefe53defb5295f6"]} \ No newline at end of file