(entries: readonly InboxEntry[])
| 30 | * display label stay distinct threads. |
| 31 | */ |
| 32 | export function groupThreads(entries: readonly InboxEntry[]): InboxThread[] { |
| 33 | const byWs = new Map<string, InboxEntry[]>() |
| 34 | for (const e of entries) { |
| 35 | const arr = byWs.get(e.workspaceId) |
| 36 | if (arr) arr.push(e) |
| 37 | else byWs.set(e.workspaceId, [e]) |
| 38 | } |
| 39 | const threads: InboxThread[] = [] |
| 40 | for (const [workspaceId, es] of byWs) { |
| 41 | threads.push({ |
| 42 | workspaceId, |
| 43 | workspaceLabel: es[0]!.workspaceLabel, |
| 44 | entries: es, |
| 45 | latestTs: es[0]!.ts, |
| 46 | }) |
| 47 | } |
| 48 | threads.sort((a, b) => b.latestTs - a.latestTs) |
| 49 | return threads |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Second-line preview text for a sidebar row — the latest push's comment |
no test coverage detected