mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-09 16:23:58 +00:00
fix(dashboard): use shared base time for connection timeline events
Connection Timeline sidebar showed only one account because generateConnectionEvents() used per-account lastUsedAt as the base timestamp. Accounts with more recent lastUsedAt dominated the recency-sorted 100-event cap. Use the maximum lastUsedAt across all accounts so events interleave proportionally. Closes #856
This commit is contained in:
@@ -44,8 +44,16 @@ export function formatTimelineTime(date: Date): string {
|
|||||||
export function generateConnectionEvents(accounts: AccountData[]): ConnectionEvent[] {
|
export function generateConnectionEvents(accounts: AccountData[]): ConnectionEvent[] {
|
||||||
const events: ConnectionEvent[] = [];
|
const events: ConnectionEvent[] = [];
|
||||||
|
|
||||||
|
// Use a shared base time so events from all accounts interleave in the timeline.
|
||||||
|
// Without this, accounts with more recent lastUsedAt dominate the sorted output.
|
||||||
|
const now = Date.now();
|
||||||
|
const sharedBaseTime = accounts.reduce((latest, a) => {
|
||||||
|
const t = a.lastUsedAt ? new Date(a.lastUsedAt).getTime() : now;
|
||||||
|
return Math.max(latest, isNaN(t) ? now : t);
|
||||||
|
}, now);
|
||||||
|
|
||||||
accounts.forEach((account) => {
|
accounts.forEach((account) => {
|
||||||
const lastUsed = account.lastUsedAt ? new Date(account.lastUsedAt) : new Date();
|
const lastUsed = new Date(sharedBaseTime);
|
||||||
|
|
||||||
// Helper to add events
|
// Helper to add events
|
||||||
const addEvents = (count: number, status: 'success' | 'failed') => {
|
const addEvents = (count: number, status: 'success' | 'failed') => {
|
||||||
|
|||||||
Reference in New Issue
Block a user