Skip to content

Commit 2283888

Browse files
committed
fix(ui): drop dead channelDisplayLabel, avoid map-spread, type zone test helper
1 parent ad14ae5 commit 2283888

4 files changed

Lines changed: 22 additions & 29 deletions

File tree

‎ui/src/components/app-sidebar-session-navigation.ts‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,19 @@ export abstract class AppSidebarSessionNavigationElement extends AppSidebarSessi
244244
);
245245
const visibleRows = limitSidebarSessionRows(expandedRows, this.visibleSessionLimit);
246246
const keep = new Set(visibleRows.map((row) => row.key));
247-
return {
248-
// totalRowCount is the pre-pagination size: headers and empty-zone
249-
// checks must not mistake a page-filtered section for an empty one.
250-
sections: sections.map((section) => ({
251-
...section,
252-
totalRowCount: section.rows.length,
253-
rows: this.isSessionSectionCollapsed(section.id)
254-
? section.rows
255-
: section.rows.filter((row) => keep.has(row.key)),
256-
})),
257-
expandedRows,
258-
visibleRows,
259-
};
247+
// totalRowCount is the pre-pagination size: headers and empty-zone
248+
// checks must not mistake a page-filtered section for an empty one.
249+
const limitedSections: (SidebarSessionSection<SidebarRecentSession> & {
250+
totalRowCount: number;
251+
})[] = [];
252+
for (const section of sections) {
253+
const totalRowCount = section.rows.length;
254+
if (!this.isSessionSectionCollapsed(section.id)) {
255+
section.rows = section.rows.filter((row) => keep.has(row.key));
256+
}
257+
limitedSections.push(Object.assign(section, { totalRowCount }));
258+
}
259+
return { sections: limitedSections, expandedRows, visibleRows };
260260
}
261261

262262
/** Rows in on-screen order; shift ranges and batch actions share this ordering. */

‎ui/src/lib/session-display.test.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, expect, it } from "vitest";
22
import {
3-
channelDisplayLabel,
43
resolveChannelSessionInfo,
54
resolveSessionDisplayName,
65
resolveSessionWorkSubtitle,
@@ -132,11 +131,3 @@ describe("resolveChannelSessionInfo", () => {
132131
});
133132
});
134133
});
135-
136-
describe("channelDisplayLabel", () => {
137-
it("uses friendly names for known channels and capitalizes the rest", () => {
138-
expect(channelDisplayLabel("imessage")).toBe("iMessage");
139-
expect(channelDisplayLabel("telegram")).toBe("Telegram");
140-
expect(channelDisplayLabel("mattermost")).toBe("Mattermost");
141-
});
142-
});

‎ui/src/lib/session-display.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ const CHANNEL_LABELS: Record<string, string> = {
1515

1616
const KNOWN_CHANNEL_KEYS = Object.keys(CHANNEL_LABELS);
1717

18-
/** Human channel label for group headers and name fallbacks. */
19-
export function channelDisplayLabel(channel: string): string {
20-
const normalized = normalizeLowercaseStringOrEmpty(channel);
21-
return CHANNEL_LABELS[normalized] ?? capitalize(normalized || channel);
22-
}
23-
2418
/** Raw peer ids stay out of the sidebar; keep a short recognizable tail only. */
2519
function shortenPeerId(identifier: string): string {
2620
const trimmed = identifier.trim();

‎ui/src/lib/sessions/grouping.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,15 @@ describe("normalizeSidebarSessionsGrouping", () => {
139139
});
140140
});
141141

142-
function row(overrides: Partial<GatewaySessionRow> & { key: string }): GatewaySessionRow {
142+
type ZoneRowExtras = {
143+
workSession?: boolean;
144+
acpSession?: boolean;
145+
channelSession?: boolean;
146+
};
147+
148+
function row(
149+
overrides: Partial<GatewaySessionRow> & ZoneRowExtras & { key: string },
150+
): GatewaySessionRow & ZoneRowExtras {
143151
return {
144152
kind: "direct",
145153
updatedAt: null,

0 commit comments

Comments
 (0)