From da1bf28e3d240838f61a5e440bb5a74f9d5d85ee Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sun, 7 Jul 2024 20:51:12 -0400 Subject: [PATCH] test --- app.js | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/app.js b/app.js index 9c3d5d7..d795b4d 100644 --- a/app.js +++ b/app.js @@ -61,32 +61,18 @@ function updatePeerCount() { } } -async function processGuild(guildTopic) { - // Simulate fetching guild data for the given topic - console.log('Processing guild for topic:', guildTopic); // Debugging log - - const guildData = { - guildTopic, - guildAlias: "Sample Guild", - rooms: [ - { topic: "room1", alias: "Room 1" }, - { topic: "room2", alias: "Room 2" } - ], - owner: config.userName - }; - - config.guilds[guildData.guildTopic] = { - alias: guildData.guildAlias, - rooms: guildData.rooms, - owner: guildData.owner +async function processGuild(guildData) { + const parsedData = JSON.parse(guildData); + config.guilds[parsedData.guildTopic] = { + alias: parsedData.guildAlias, + rooms: parsedData.rooms, + owner: parsedData.owner }; writeConfigToFile("./config.json"); renderGuildList(); - await joinGuild(guildData.guildTopic); + await joinGuild(parsedData.guildTopic); } -export { processGuild }; - async function joinGuild(guildTopic) { const guild = config.guilds[guildTopic]; if (guild) { @@ -209,7 +195,6 @@ function setupEventListeners() { const attachFileButton = document.getElementById('attach-file'); const fileInput = document.getElementById('file-input'); const talkButton = document.getElementById('talk-btn'); - const joinGuildBtn = document.getElementById('join-guild'); if (registerForm) { registerForm.addEventListener('submit', registerUser); @@ -249,17 +234,6 @@ function setupEventListeners() { if (talkButton) { setupTalkButton(); } - if (joinGuildBtn) { - joinGuildBtn.addEventListener('click', async (event) => { - const guildTopic = document.getElementById('join-guild-topic').value.trim(); - if (guildTopic) { - console.log('Join Guild button clicked with topic:', guildTopic); // Debugging log - await processGuild(guildTopic); - } else { - console.error('Guild topic is empty'); - } - }); - } // Add event listeners only for room items document.querySelectorAll('.room-item').forEach(item => { @@ -1233,4 +1207,4 @@ function handleFileInput(event) { } } -initialize(); +initialize(); \ No newline at end of file