Skip to content

Commit bf89dc4

Browse files
authored
[UK-860] Fix issues of event filter and Add tests (#11)
- Do not check readMessageCount condition when channelListQuery exist - Fix issue in CREATE_CHANNEL / create channel because of object destruction in reducers - Fix messageId comparison in on message updated - Fix binarySearch when targetIndex is 0 before it pushes the target item to the second position - Add tests for events filter
1 parent 5a59510 commit bf89dc4

File tree

9 files changed

+1192
-52
lines changed

9 files changed

+1192
-52
lines changed

src/smart-components/App/stories/index.stories.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import React, { useEffect, useState } from 'react';
33
import pkg from '../../../../package-lock.json'
44

55
import App from '../index';
6+
import Sendbird from '../../../lib/Sendbird';
7+
import ChannelList from '../../ChannelList';
8+
import Conversation from '../../Conversation';
9+
import ChannelSettings from '../../ChannelSettings';
10+
import MessageSearch from '../../MessageSearch';
11+
import { withSendBird } from '../../..';
12+
import { sendBirdSelectors } from '../../..';
613
import { fitPageSize } from './utils';
14+
715
const appId = process.env.STORYBOOK_APP_ID;
816
// const userId = 'leo.sub';
917
const userId = 'sendbird';
@@ -159,6 +167,7 @@ const array = [
159167
`hoon${age}1`,
160168
`hoon${age}2`,
161169
`hoon${age}3`,
170+
`eunseo${age}1`,
162171
];
163172
const addProfile = null; // 'https://static.sendbird.com/sample/profiles/profile_12_512px.png';
164173

@@ -186,6 +195,7 @@ export const user1 = () => fitPageSize(
186195
allowProfileEdit
187196
profileUrl={addProfile}
188197
config={{ logLevel: 'all' }}
198+
queries={{}}
189199
/>
190200
);
191201
export const user2 = () => fitPageSize(
@@ -216,6 +226,83 @@ export const user3 = () => fitPageSize(
216226
/>
217227
);
218228

229+
const UseSendbirdChannelList = (props) => {
230+
const [queries] = useState({ channelListQuery: { customTypesFilter: ['apple'] } });
231+
const sdk = sendBirdSelectors.getSdk(props);
232+
const { setChannelUrl } = props;
233+
234+
return (
235+
<ChannelList
236+
onChannelSelect={(channel) => channel && setChannelUrl(channel.url)}
237+
queries={queries}
238+
onBeforeCreateChannel={(selectedUserIds) => {
239+
const params = new sdk.GroupChannelParams();
240+
params.addUserIds(selectedUserIds);
241+
params.isDistinct = false;
242+
params.customType = 'apple';
243+
return params;
244+
}}
245+
/>
246+
);
247+
};
248+
const SBChannelList = withSendBird(UseSendbirdChannelList);
249+
const CustomApp = () => {
250+
const [channelUrl, setChannelUrl] = useState('');
251+
const [channelSettings, setChannelSettings] = useState(false);
252+
const [channelSearch, setChannelSearch] = useState(false);
253+
return (
254+
<Sendbird
255+
appId={appId}
256+
userId={array[3]}
257+
nickname={array[3]}
258+
theme="dark"
259+
showSearchIcon
260+
allowProfileEdit
261+
profileUrl={addProfile}
262+
imageCompression={{ compressionRate: 0.5, resizingWidth: 100, resizingHeight: '100px' }}
263+
>
264+
<div style={{ height: '100%', width: '100%', display: 'flex', flexDirection: 'row' }}>
265+
<SBChannelList setChannelUrl={setChannelUrl} />
266+
<div style={{ height: '100%', width: '100%', display: 'inline-flex', flexDirection: 'row' }}>
267+
<div style={{ width: '100%' }}>
268+
<Conversation
269+
channelUrl={channelUrl}
270+
onChatHeaderActionClick={() => {
271+
setChannelSearch(false);
272+
setChannelSettings(true);
273+
}}
274+
showSearchIcon
275+
onSearchClick={() => {
276+
setChannelSettings(false);
277+
setChannelSearch(true);
278+
}}
279+
/>
280+
</div>
281+
{channelSearch && (
282+
<div style={{ width: '100%' }}>
283+
<MessageSearch
284+
channelUrl={channelUrl}
285+
searchString="hello"
286+
onResultClick={() => {}}
287+
/>
288+
</div>
289+
)}
290+
{channelSettings && (
291+
<div style={{ display: 'inline-flex'}}>
292+
<ChannelSettings
293+
channelUrl={channelUrl}
294+
onCloseClick={() => setChannelSettings(false)}
295+
/>
296+
</div>
297+
)}
298+
</div>
299+
</div>
300+
</Sendbird>
301+
);
302+
};
303+
304+
export const customer1 = () => fitPageSize(<CustomApp />);
305+
219306
export const disableUserProfile = () => fitPageSize(
220307
<App
221308
showSearchIcon

0 commit comments

Comments
 (0)