diff --git a/web/public/assets/js/app/__tests__/chat-log-tabs.test.js b/web/public/assets/js/app/__tests__/chat-log-tabs.test.js index e20d0d3..008f278 100644 --- a/web/public/assets/js/app/__tests__/chat-log-tabs.test.js +++ b/web/public/assets/js/app/__tests__/chat-log-tabs.test.js @@ -113,11 +113,9 @@ test('buildChatTabModel returns sorted nodes and channel buckets', () => { assert.deepEqual(secondaryChannel.entries.map(entry => entry.message.id), ['iso-ts', 'recent-alt']); }); -test('buildChatTabModel always includes channel zero bucket', () => { +test('buildChatTabModel skips channel buckets when there are no messages', () => { const model = buildChatTabModel({ nodes: [], messages: [], nowSeconds: NOW, windowSeconds: WINDOW }); - assert.equal(model.channels.length, 1); - assert.equal(model.channels[0].index, 0); - assert.equal(model.channels[0].entries.length, 0); + assert.equal(model.channels.length, 0); }); test('buildChatTabModel falls back to numeric label when no metadata provided', () => { diff --git a/web/public/assets/js/app/chat-log-tabs.js b/web/public/assets/js/app/chat-log-tabs.js index 1923673..3ed638c 100644 --- a/web/public/assets/js/app/chat-log-tabs.js +++ b/web/public/assets/js/app/chat-log-tabs.js @@ -65,7 +65,8 @@ function resolveSnapshotList(entry) { * Build a data model describing the content for chat tabs. * * Entries outside the recent activity window, encrypted messages, and - * channels above {@link MAX_CHANNEL_INDEX} are filtered out. + * channels above {@link MAX_CHANNEL_INDEX} are filtered out. Channel + * buckets are only created when messages are present for that channel. * * @param {{ * nodes?: Array, @@ -287,26 +288,6 @@ export function buildChatTabModel({ logEntries.sort((a, b) => a.ts - b.ts); - let hasPrimaryBucket = false; - for (const bucket of channelBuckets.values()) { - if (bucket.index === 0) { - hasPrimaryBucket = true; - break; - } - } - if (!hasPrimaryBucket) { - const bucketKey = '0'; - channelBuckets.set(bucketKey, { - key: bucketKey, - id: buildChannelTabId(bucketKey), - index: 0, - label: '0', - entries: [], - labelPriority: CHANNEL_LABEL_PRIORITY.INDEX, - isPrimaryFallback: true - }); - } - const channels = Array.from(channelBuckets.values()).sort((a, b) => { if (a.index !== b.index) { return a.index - b.index;