Fix Sidebar render purity for history bucket grouping
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Navigation sidebar with menu items.
|
||||
* No longer fixed - sits inside the flex layout below the title bar.
|
||||
*/
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { NavLink, useLocation, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Home,
|
||||
@@ -92,6 +92,8 @@ function getSessionBucket(activityMs: number, nowMs: number): SessionBucketKey {
|
||||
return 'older';
|
||||
}
|
||||
|
||||
const INITIAL_NOW_MS = Date.now();
|
||||
|
||||
export function Sidebar() {
|
||||
const sidebarCollapsed = useSettingsStore((state) => state.sidebarCollapsed);
|
||||
const setSidebarCollapsed = useSettingsStore((state) => state.setSidebarCollapsed);
|
||||
@@ -130,7 +132,14 @@ export function Sidebar() {
|
||||
|
||||
const { t } = useTranslation(['common', 'chat']);
|
||||
const [sessionToDelete, setSessionToDelete] = useState<{ key: string; label: string } | null>(null);
|
||||
const nowMs = Date.now();
|
||||
const [nowMs, setNowMs] = useState(INITIAL_NOW_MS);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = window.setInterval(() => {
|
||||
setNowMs(Date.now());
|
||||
}, 60 * 1000);
|
||||
return () => window.clearInterval(timer);
|
||||
}, []);
|
||||
const sessionBuckets: Array<{ key: SessionBucketKey; label: string; sessions: typeof sessions }> = [
|
||||
{ key: 'today', label: t('chat:historyBuckets.today'), sessions: [] },
|
||||
{ key: 'yesterday', label: t('chat:historyBuckets.yesterday'), sessions: [] },
|
||||
|
||||
Reference in New Issue
Block a user