diff --git a/public/sidebar/sidebar.html b/public/sidebar/sidebar.html
index 39a4053..84bbded 100644
--- a/public/sidebar/sidebar.html
+++ b/public/sidebar/sidebar.html
@@ -10,23 +10,20 @@
}
});
- function update_topic_indicators() {
- const topic_indicators = document.querySelectorAll("[data-topic-selector-for]");
- for (const topic_indicator of topic_indicators) {
- topic_indicator.classList.remove("active");
- }
+ function update_topic_indicators(event) {
+ document
+ .querySelectorAll("[data-topic-selector-for]")
+ .forEach((element) => element.classList.remove("active"));
- const topic_id = document.body.dataset.topic;
- if (!topic_id) {
+ const new_topic_id = event?.detail?.topic_id ?? document.body.dataset.topic;
+
+ if (!new_topic_id) {
return;
}
- const active_topic_indicators = document.querySelectorAll(
- `[data-topic-selector-for="${topic_id}"]`,
- );
- for (const active_indicator of active_topic_indicators) {
- active_indicator.classList.add("active");
- }
+ document
+ .querySelectorAll(`[data-topic-selector-for="${new_topic_id}"]`)
+ .forEach((element) => element.classList.add("active"));
}
document.addEventListener("topics_updated", update_topic_indicators);
diff --git a/public/tabs/chat/chat.html b/public/tabs/chat/chat.html
index dacfde6..70670d9 100644
--- a/public/tabs/chat/chat.html
+++ b/public/tabs/chat/chat.html
@@ -129,11 +129,12 @@
const topic_id = event?.detail?.topic_id ?? document.body.dataset.topic;
if (!topic_id) return;
+ const topic_chat_content = document.getElementById("topic-chat-content");
+ topic_chat_content.innerHTML = "";
+
const user = document.body.dataset.user ? JSON.parse(document.body.dataset.user) : null;
if (!user) return;
- const topic_chat_content = document.getElementById("topic-chat-content");
-
if (topic_polling_request_abort_controller) {
topic_polling_request_abort_controller.abort();
topic_polling_request_abort_controller = null;
@@ -149,8 +150,6 @@
const topic = await topic_response.json();
- topic_chat_content.innerHTML = "";
-
const events_response = await api.fetch(
`/api/topics/${topic_id}/events?type=chat&limit=100&sort=newest`,
);