diff --git a/src/components/messenger/list/conversation-list-panel/index.test.tsx b/src/components/messenger/list/conversation-list-panel/index.test.tsx index 3230a97db..19d6eae14 100644 --- a/src/components/messenger/list/conversation-list-panel/index.test.tsx +++ b/src/components/messenger/list/conversation-list-panel/index.test.tsx @@ -358,6 +358,19 @@ describe('ConversationListPanel', () => { 'convo-4', ]); }); + + it('filters archived conversations', () => { + const archivedConversations = [ + stubConversation({ name: 'convo-1', labels: [] }), + stubConversation({ name: 'convo-2', labels: [DefaultRoomLabels.ARCHIVED] }), + stubConversation({ name: 'convo-3', labels: [DefaultRoomLabels.ARCHIVED] }), + ]; + const wrapper = subject({ conversations: archivedConversations as any }); + + wrapper.find('Input').simulate('change', 'convo'); + const displayChatNames = renderedConversations(wrapper).map((c) => c.name); + expect(displayChatNames).toStrictEqual(['convo-1']); + }); }); it('selecting an existing conversation announces click event', async function () { diff --git a/src/components/messenger/list/conversation-list-panel/index.tsx b/src/components/messenger/list/conversation-list-panel/index.tsx index 0f9566283..de3d84e35 100644 --- a/src/components/messenger/list/conversation-list-panel/index.tsx +++ b/src/components/messenger/list/conversation-list-panel/index.tsx @@ -111,6 +111,10 @@ export class ConversationListPanel extends React.Component { } get filteredConversations() { + const archivedConversationIds = this.props.conversations + .filter((c) => c.labels?.includes(DefaultRoomLabels.ARCHIVED)) + .map((c) => c.id); + if (!this.state.filter) { return this.getTabConversations()[this.state.selectedTab]; } @@ -119,7 +123,7 @@ export class ConversationListPanel extends React.Component { const directMatches = getDirectMatches(this.props.conversations, searchRegEx); const indirectMatches = getIndirectMatches(this.props.conversations, searchRegEx); - return [...directMatches, ...indirectMatches]; + return [...directMatches, ...indirectMatches].filter((c) => !archivedConversationIds.includes(c.id)); } openExistingConversation = (id: string) => {