Skip to content

Commit 1733849

Browse files
authored
fix: remove component in the view layer (#958)
- Remove AddChannel component from the view layer
1 parent 77cbfa0 commit 1733849

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

src/modules/ChannelList/components/ChannelListUI/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as channelListActions from '../../dux/actionTypes';
99

1010
import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext';
1111
import { GroupChannelListUIView } from '../../../GroupChannelList/components/GroupChannelListUI/GroupChannelListUIView';
12+
import AddChannel from '../AddChannel';
1213

1314
interface RenderChannelPreviewProps {
1415
channel: GroupChannel;
@@ -127,6 +128,7 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (
127128
channels={allChannels}
128129
onLoadMore={fetchChannelList}
129130
initialized={initialized}
131+
renderAddChannel={() => <AddChannel />}
130132
/>
131133
);
132134
};

src/modules/GroupChannelList/components/GroupChannelListUI/GroupChannelListUIView.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
22
import type { GroupChannel } from '@sendbird/chat/groupChannel';
33

44
import GroupChannelListHeader from '../GroupChannelListHeader';
5-
import AddChannel from '../AddGroupChannel';
65

76
import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext';
87
import EditUserProfile from '../../../EditUserProfile';
@@ -17,16 +16,15 @@ export interface Props {
1716
renderPlaceHolderEmptyList?: (props: void) => React.ReactElement;
1817

1918
onChangeTheme: (theme: string) => void;
20-
onUserProfileUpdated: (user:User)=>void;
19+
onUserProfileUpdated: (user: User) => void;
2120
allowProfileEdit: boolean;
2221

2322
channels: GroupChannel[];
2423
onLoadMore: () => void;
2524
initialized: boolean;
26-
renderChannel: (props: {
27-
item: GroupChannel;
28-
index: number;
29-
}) => React.ReactElement;
25+
renderChannel: (props: { item: GroupChannel; index: number }) => React.ReactElement;
26+
27+
renderAddChannel(): React.ReactElement;
3028
}
3129

3230
export const GroupChannelListUIView = ({
@@ -43,11 +41,14 @@ export const GroupChannelListUIView = ({
4341
onLoadMore,
4442
initialized,
4543
renderChannel,
44+
45+
renderAddChannel,
4646
}: Props) => {
4747
const [showProfileEdit, setShowProfileEdit] = useState(false);
4848
const { stores } = useSendbirdStateContext();
4949

5050
const renderer = {
51+
addChannel: renderAddChannel,
5152
channel: renderChannel,
5253
placeholder: {
5354
loading() {
@@ -78,7 +79,7 @@ export const GroupChannelListUIView = ({
7879
<GroupChannelListHeader
7980
onEdit={() => allowProfileEdit && setShowProfileEdit(true)}
8081
allowProfileEdit={allowProfileEdit}
81-
renderIconButton={() => <AddChannel />}
82+
renderIconButton={() => renderer.addChannel()}
8283
/>
8384
)}
8485
</div>
@@ -120,14 +121,7 @@ const ChannelListComponent = <T, >(props: {
120121
placeholderEmpty?: React.ReactNode;
121122
placeholderError?: React.ReactNode;
122123
}) => {
123-
const {
124-
data,
125-
renderItem,
126-
onLoadMore,
127-
placeholderLoading,
128-
placeholderError,
129-
placeholderEmpty,
130-
} = props;
124+
const { data, renderItem, onLoadMore, placeholderLoading, placeholderError, placeholderEmpty } = props;
131125

132126
const onScroll = useOnScrollPositionChangeDetector({
133127
onReachedBottom: () => onLoadMore(),

src/modules/GroupChannelList/components/GroupChannelListUI/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { GroupChannelListUIView } from './GroupChannelListUIView';
77
import GroupChannelPreviewAction from '../GroupChannelPreviewAction';
88
import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext';
99
import { GroupChannelListItem } from '../GroupChannelListItem';
10+
import AddGroupChannel from '../AddGroupChannel';
1011

1112
interface RenderChannelPreviewProps {
1213
channel: GroupChannel;
@@ -111,6 +112,7 @@ export const GroupChannelListUI = (props: GroupChannelListUIProps) => {
111112
channels={groupChannels}
112113
onLoadMore={loadMore}
113114
initialized={initialized}
115+
renderAddChannel={() => <AddGroupChannel />}
114116
/>
115117
);
116118
};

0 commit comments

Comments
 (0)