Skip to content

Commit

Permalink
refactor(feed-chat): reduce unnecessary DOM elements by conditionally…
Browse files Browse the repository at this point in the history
… rendering MembersSidekick to improve performance
  • Loading branch information
domw30 committed Mar 7, 2025
1 parent cc83b01 commit 2172f65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/apps/feed/components/feed-chat/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { validateFeedChat } from '../../../../store/chat';
import { send } from '../../../../store/messages';
import { config } from '../../../../config';
import { Spinner } from '@zero-tech/zui/components/LoadingIndicator';
import { MembersSidekick } from '../../../../components/sidekick/variants/members-sidekick';

describe('FeedChatContainer', () => {
const subject = (props: any = {}) => {
Expand Down Expand Up @@ -135,6 +136,19 @@ describe('FeedChatContainer', () => {
expect(validateFeedChat).toHaveBeenLastCalledWith(`new-zid:${config.matrixHomeServerName}`);
});

it('should render members sidekick when is secondary sidekick open', () => {
const wrapper = subject({
zid: 'test-zid',
channel: { id: 'channel-id' },
activeConversationId: 'conversation-id',
isJoiningConversation: true,
isConversationsLoaded: true,
isSecondarySidekickOpen: true,
});

expect(wrapper).toHaveElement(MembersSidekick);
});

describe('mapState', () => {
const getState = (state: any) =>
({
Expand Down
2 changes: 1 addition & 1 deletion src/apps/feed/components/feed-chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class Container extends React.Component<Properties> {
{this.renderHeader()}{' '}
{this.renderBody(this.props.isJoiningConversation || !this.props.isConversationsLoaded)}
</Panel>
<MembersSidekick className={styles.MembersSidekick} />
{this.props.isSecondarySidekickOpen && <MembersSidekick className={styles.MembersSidekick} />}
</>
)}
</>
Expand Down

0 comments on commit 2172f65

Please sign in to comment.