Fixed rooms not being deleted from the json file #4

Merged
snxraven merged 10 commits from MiTask/LinkUp-P2P-Chat:main into main 2024-06-09 04:20:00 -04:00
Showing only changes of commit 840b6e2069 - Show all commits

8
app.js
View File

@ -278,14 +278,15 @@ function leaveRoom() {
if (roomItem) { if (roomItem) {
roomItem.remove(); roomItem.remove();
} }
config.rooms = config.rooms.filter(e => e !== currentRoom.topic);
writeConfigToFile("./config.json");
currentRoom.destroy(); currentRoom.destroy();
currentRoom = null; currentRoom = null;
} }
document.querySelector('#chat').classList.add('hidden'); document.querySelector('#chat').classList.add('hidden');
document.querySelector('#setup').classList.remove('hidden'); document.querySelector('#setup').classList.remove('hidden');
config.rooms = config.rooms.filter(e => e !== currentRoom.topic);
writeConfigToFile("./config.json");
} }
function sendMessage(e) { function sendMessage(e) {
@ -438,7 +439,6 @@ function toggleSetupView() {
} }
function writeConfigToFile(filePath) { function writeConfigToFile(filePath) {
console.debug(config)
fs.writeFile(filePath, JSON.stringify(config), (err) => { fs.writeFile(filePath, JSON.stringify(config), (err) => {
if (err) return console.error(err); if (err) return console.error(err);
console.log("File has been created"); console.log("File has been created");