FIX: always render "today" on top of conversation sidebar (#1400)

This commit is contained in:
Kris 2025-06-03 14:52:12 -04:00 committed by GitHub
parent 59f4b66ede
commit 4f980d5514
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 4 deletions

View File

@ -216,6 +216,13 @@ export default class AiConversationsSidebarManager extends Service {
const now = Date.now();
const fresh = [];
const todaySection = {
name: "today",
title: i18n("discourse_ai.ai_bot.conversations.today"),
links: new TrackedArray(),
};
fresh.push(todaySection);
this.topics.forEach((t) => {
const postedAtMs = new Date(t.last_posted_at || now).valueOf();
const diffDays = Math.floor((now - postedAtMs) / 86400000);
@ -233,13 +240,16 @@ export default class AiConversationsSidebarManager extends Service {
dateGroup = key;
}
let sec = fresh.find((s) => s.name === dateGroup);
let sec;
if (dateGroup === "today") {
sec = todaySection;
} else {
sec = fresh.find((s) => s.name === dateGroup);
}
if (!sec) {
let title;
switch (dateGroup) {
case "today":
title = i18n("discourse_ai.ai_bot.conversations.today");
break;
case "last-7-days":
title = i18n("discourse_ai.ai_bot.conversations.last_7_days");
break;

View File

@ -23,6 +23,11 @@ body.has-ai-conversations-sidebar {
}
}
// we always have the "today" section rendered at the top of the sidebar but hide it when empty
.sidebar-section[data-section-name="today"]:has(.ai-bot-sidebar-empty-state) {
display: none;
}
.sidebar-toggle-all-sections {
display: none;
}