From ff4027d41d9cbcdf2688d25feeeb06cc280254d1 Mon Sep 17 00:00:00 2001 From: bitkarrot <73979971+bitkarrot@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:25:42 -0700 Subject: [PATCH] fix exceptions where no meetings --- app/src/Server.js | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/app/src/Server.js b/app/src/Server.js index f45d4ca2..34fd76f6 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -444,31 +444,40 @@ function startServer() { } app.get('/active', (req, res) => { - let meetings = getMeetCount(roomList); - // console.log(meetings) + let currentYear = new Date().getFullYear() let activeHtml = fs.readFileSync(path.join(__dirname, '../../', 'public/views/active.html'), 'utf8'); - - const dynamicContent = { - currentYear: new Date().getFullYear(), - rooms: meetings, + activeHtml = activeHtml.replace('{{currentYear}}', currentYear); + let roomsHtml = '0'; + try { + let meetings = getMeetCount(roomList); + //console.log("meetings", meetings) + //console.log("meetings length", meetings.length) + + if (meetings?.length) { + // Create HTML for room data matching the client-side structure + // console.log("meetings available") + roomsHtml = meetings.map(room => ` + +
+

Room ID: ${room.roomId}

+ Bees: ${room.peerCount} +
+
+ `).join(''); + // console.log("roomsHtml", roomsHtml) + // Replace room data placeholder + activeHtml = activeHtml.replace('{{activeMeetings}}', roomsHtml); + } + else { + activeHtml = activeHtml.replace('{{activeMeetings}}', ''); + } + res.send(activeHtml); + } catch (err) { + console.log("error in active meetings", err) + res.send(activeHtml); } - activeHtml = activeHtml.replace('{{currentYear}}', dynamicContent.currentYear); - - // Create HTML for room data matching the client-side structure - const roomsHtml = dynamicContent.rooms.map(room => ` - -
-

Room ID: ${room.roomId}

- Bees: ${room.peerCount} -
-
- `).join(''); - - // Replace room data placeholder - activeHtml = activeHtml.replace('{{activeMeetings}}', roomsHtml); - res.send(activeHtml); }); - + // Route to display user information app.get('/profile', OIDCAuth, (req, res) => {