From 7a74d3fc4d17b4ef6d2d84b04b1293ef034abfad Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Tue, 11 Jun 2024 02:52:53 -0400 Subject: [PATCH] Add room names to room view header, add a copy topic button and remove the display of the topics --- app.js | 28 ++++++++++++++++++++- index.html | 74 ++++++++++++++++++++++++++++++++++++++++++++++++------ style.css | 21 ++++++++++++++++ 3 files changed, 114 insertions(+), 9 deletions(-) diff --git a/app.js b/app.js index d1a2bdd..fa93d67 100644 --- a/app.js +++ b/app.js @@ -313,6 +313,15 @@ function exitEditMode(roomItem, input, topic) { roomConfig.alias = newAlias; writeConfigToFile("./config.json"); } + + // Check if the edited room is the current room in view + const currentTopic = document.querySelector('#chat-room-topic').innerText; + if (currentTopic === topic) { + const chatRoomName = document.querySelector('#chat-room-name'); + if (chatRoomName) { + chatRoomName.innerText = newAlias; + } + } } else { roomItem.textContent = truncateHash(topic); } @@ -320,7 +329,24 @@ function exitEditMode(roomItem, input, topic) { function switchRoom(topic) { console.log('Switching to room:', topic); // Debugging log - document.querySelector('#chat-room-topic').innerText = topic; // Set full topic here + const chatRoomTopic = document.querySelector('#chat-room-topic'); + const chatRoomName = document.querySelector('#chat-room-name'); + + if (chatRoomTopic) { + chatRoomTopic.innerText = topic; // Set full topic here + } else { + console.error('Element #chat-room-topic not found'); + } + + if (chatRoomName) { + // Update the room name in the header + const room = config.rooms.find(r => r.topic === topic); + const roomName = room ? room.alias : truncateHash(topic); + chatRoomName.innerText = roomName; + } else { + console.error('Element #chat-room-name not found'); + } + clearMessages(); renderMessagesForRoom(topic); diff --git a/index.html b/index.html index 4790ea1..18781d1 100644 --- a/index.html +++ b/index.html @@ -46,10 +46,9 @@