Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): show an empty state when no channel matches a search

Yudhi Armyndharisf3a5ff6fbb3a
diff --git a/dashboard/src/components/chats/ChatSidebar.test.ts b/dashboard/src/components/chats/ChatSidebar.test.ts
index 48ab17cf5..7dc7ce446 100644
--- a/dashboard/src/components/chats/ChatSidebar.test.ts
+++ b/dashboard/src/components/chats/ChatSidebar.test.ts
@@ -97,3 +97,9 @@ test('a chat marked unread (count -1) shows an unread badge without a number', (
],
);
});
+
+test('a channel search with no match says so instead of showing a blank list', () => {
+ const channel = { id: '1@newsletter', name: 'News' } as Channel;
+ const { container } = renderSidebar('channels', [], { all: [channel], shown: [] });
+ assert.equal(container.querySelector('.chats-list-empty')?.textContent, t('chats.empty'));
+});
diff --git a/dashboard/src/components/chats/ChatSidebar.tsx b/dashboard/src/components/chats/ChatSidebar.tsx
index 9a6d825ad..4c76e5556 100644
--- a/dashboard/src/components/chats/ChatSidebar.tsx
+++ b/dashboard/src/components/chats/ChatSidebar.tsx
@@ -229,6 +229,11 @@ function ChatSidebar({
<div className="chats-list-empty">
<span>{t('chats.channels.empty')}</span>
</div>
+ ) : channelsTab.channels.length === 0 ? (
+ // Subscribed, but the search matches none of them.
+ <div className="chats-list-empty">
+ <span>{t('chats.empty')}</span>
+ </div>
) : (
channelsTab.channels.map(ch => (
<div