Skip to content

Commit 19b8731

Browse files
authored
chore: prepare collection publish (#976)
- Update default values to publish GroupChannel and GroupChannelList modules. - Export components - Fixed a bug where isUserIdUsedForNickname is not working - Update chat sdk version - Update uikit-tools version
1 parent fabda2e commit 19b8731

File tree

19 files changed

+169
-304
lines changed

19 files changed

+169
-304
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
"react-dom": "^16.8.6 || ^17.0.0 || ^18.0.0"
6868
},
6969
"dependencies": {
70-
"@sendbird/chat": "^4.10.8",
71-
"@sendbird/uikit-tools": "0.0.1-alpha.61",
70+
"@sendbird/chat": "^4.10.9",
71+
"@sendbird/uikit-tools": "0.0.1-alpha.62",
7272
"css-vars-ponyfill": "^2.3.2",
7373
"date-fns": "^2.16.1",
7474
"dompurify": "^3.0.1"

rollup.module-exports.mjs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default {
3636
'utils/message/getOutgoingMessageState': 'src/utils/exports/getOutgoingMessageState.ts',
3737
'utils/message/isVoiceMessage': 'src/utils/isVoiceMessage.ts',
3838

39-
// ChannelList
39+
// ChannelList - legacy
4040
ChannelList: 'src/modules/ChannelList/index.tsx',
4141
'ChannelList/context': 'src/modules/ChannelList/context/ChannelListProvider.tsx',
4242
'ChannelList/components/AddChannel': 'src/modules/ChannelList/components/AddChannel/index.tsx',
@@ -45,6 +45,15 @@ export default {
4545
'ChannelList/components/ChannelPreview': 'src/modules/ChannelList/components/ChannelPreview/index.tsx',
4646
'ChannelList/components/ChannelPreviewAction': 'src/modules/ChannelList/components/ChannelPreviewAction.tsx',
4747

48+
// GroupChannelList
49+
GroupChannelList: 'src/modules/GroupChannelList/index.tsx',
50+
'GroupChannelList/context': 'src/modules/GroupChannelList/context/GroupChannelListProvider.tsx',
51+
'GroupChannelList/components/AddGroupChannel': 'src/modules/GroupChannelList/components/AddGroupChannel/index.tsx',
52+
'GroupChannelList/components/GroupChannelListUI': 'src/modules/GroupChannelList/components/GroupChannelListUI/index.tsx',
53+
'GroupChannelList/components/GroupChannelListHeader': 'src/modules/GroupChannelList/components/GroupChannelListHeader/index.tsx',
54+
'GroupChannelList/components/GroupChannelListItem': 'src/modules/GroupChannelList/components/GroupChannelListItem/index.tsx',
55+
'GroupChannelList/components/GroupChannelPreviewAction': 'src/modules/GroupChannelList/components/GroupChannelPreviewAction.tsx',
56+
4857
// ChannelSettings
4958
ChannelSettings: 'src/modules/ChannelSettings/index.tsx',
5059
'ChannelSettings/context': 'src/modules/ChannelSettings/context/ChannelSettingsProvider.tsx',
@@ -56,7 +65,7 @@ export default {
5665
'ChannelSettings/components/UserListItem': 'src/modules/ChannelSettings/components/UserListItem/index.tsx',
5766
'ChannelSettings/components/UserPanel': 'src/modules/ChannelSettings/components/UserPanel/index.tsx',
5867

59-
// Channel
68+
// Channel - legacy
6069
Channel: 'src/modules/Channel/index.tsx',
6170
'Channel/context': 'src/modules/Channel/context/ChannelProvider.tsx',
6271
'Channel/hooks/useInitialMessagesFetch': 'src/modules/Channel/context/hooks/useInitialMessagesFetch.ts',
@@ -69,14 +78,29 @@ export default {
6978
'Channel/components/FrozenNotification': 'src/modules/Channel/components/FrozenNotification/index.tsx',
7079
'Channel/components/Message': 'src/modules/Channel/components/Message/index.tsx',
7180
'Channel/components/MessageInput': 'src/modules/Channel/components/MessageInputWrapper/index.tsx',
81+
'Channel/components/MessageInputWrapper': 'src/modules/Channel/components/MessageInputWrapper/index.tsx',
7282
'Channel/components/MessageList': 'src/modules/Channel/components/MessageList/index.tsx',
7383
'Channel/components/RemoveMessageModal': 'src/modules/Channel/components/RemoveMessageModal/index.tsx',
7484
'Channel/components/MessageFeedbackModal': 'src/modules/Channel/components/MessageFeedbackModal/index.tsx',
7585
'Channel/components/TypingIndicator': 'src/modules/Channel/components/TypingIndicator.tsx',
7686
'Channel/components/UnreadCount': 'src/modules/Channel/components/UnreadCount/index.tsx',
7787
'Channel/components/SuggestedMentionList': 'src/modules/Channel/components/SuggestedMentionList/index.tsx',
7888

79-
// TODO: Export components for GroupChannel
89+
GroupChannel: 'src/modules/GroupChannel/index.tsx',
90+
'GroupChannel/context': 'src/modules/GroupChannel/context/GroupChannelProvider.tsx',
91+
'GroupChannel/components/GroupChannelHeader': 'src/modules/GroupChannel/components/GroupChannelHeader/index.tsx',
92+
'GroupChannel/components/GroupChannelUI': 'src/modules/GroupChannel/components/GroupChannelUI/index.tsx',
93+
'GroupChannel/components/FileViewer': 'src/modules/GroupChannel/components/FileViewer/index.tsx',
94+
'GroupChannel/components/FrozenNotification': 'src/modules/GroupChannel/components/FrozenNotification/index.tsx',
95+
'GroupChannel/components/Message': 'src/modules/GroupChannel/components/Message/index.tsx',
96+
'GroupChannel/components/MessageInputWrapper': 'src/modules/GroupChannel/components/MessageInputWrapper/index.tsx',
97+
'GroupChannel/components/MessageList': 'src/modules/GroupChannel/components/MessageList/index.tsx',
98+
'GroupChannel/components/RemoveMessageModal': 'src/modules/GroupChannel/components/RemoveMessageModal/index.tsx',
99+
'GroupChannel/components/TypingIndicator': 'src/modules/GroupChannel/components/TypingIndicator.tsx',
100+
'GroupChannel/components/UnreadCount': 'src/modules/GroupChannel/components/UnreadCount/index.tsx',
101+
'GroupChannel/components/SuggestedMentionList': 'src/modules/GroupChannel/components/SuggestedMentionList/index.tsx',
102+
'GroupChannel/components/SuggestedReplies': 'src/modules/GroupChannel/components/SuggestedReplies/index.tsx',
103+
// 'GroupChannel/components/MessageFeedbackModal': 'src/modules/GroupChannel/components/MessageFeedbackModal/index.tsx', // TODO: move to UI
80104

81105
// OpenChannel
82106
OpenChannel: 'src/modules/OpenChannel/index.tsx',

src/lib/hooks/useConnect/__test__/setupConnection.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ describe('useConnect/setupConnection/setUpParams', () => {
191191
expect(require('@sendbird/chat').init).toBeCalledWith({
192192
appId,
193193
newInstance: true,
194-
localCacheEnabled: false,
194+
localCacheEnabled: true,
195195
modules: [
196196
// @ts-ignore
197197
new (require('@sendbird/chat/groupChannel').GroupChannelModule)(),
@@ -210,7 +210,7 @@ describe('useConnect/setupConnection/setUpParams', () => {
210210
expect(require('@sendbird/chat').init).toBeCalledWith({
211211
appId,
212212
newInstance: true,
213-
localCacheEnabled: false,
213+
localCacheEnabled: true,
214214
modules: [
215215
// @ts-ignore
216216
new (require('@sendbird/chat/groupChannel').GroupChannelModule)(),
@@ -231,7 +231,7 @@ describe('useConnect/setupConnection/setUpParams', () => {
231231
expect(require('@sendbird/chat').init).toBeCalledWith({
232232
appId,
233233
newInstance: true,
234-
localCacheEnabled: false,
234+
localCacheEnabled: true,
235235
modules: [
236236
// @ts-ignore
237237
new (require('@sendbird/chat/groupChannel').GroupChannelModule)(),
@@ -251,7 +251,7 @@ describe('useConnect/setupConnection/setUpParams', () => {
251251
expect(require('@sendbird/chat').init).toBeCalledWith({
252252
appId,
253253
newInstance: true,
254-
localCacheEnabled: false,
254+
localCacheEnabled: true,
255255
modules: [
256256
// @ts-ignore
257257
new (require('@sendbird/chat/groupChannel').GroupChannelModule)(),

src/lib/hooks/useConnect/connect.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export async function connect({
2020
customExtensionParams,
2121
isMobile,
2222
eventHandlers,
23+
isUserIdUsedForNickname,
2324
}: ConnectTypes): Promise<void> {
2425
await disconnectSdk({
2526
logger,
@@ -44,5 +45,6 @@ export async function connect({
4445
customExtensionParams,
4546
isMobile,
4647
eventHandlers,
48+
isUserIdUsedForNickname,
4749
});
4850
}

src/lib/hooks/useConnect/setupConnection.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ export function setUpParams({
3838
appId,
3939
modules: [new GroupChannelModule(), new OpenChannelModule()],
4040
newInstance: true,
41-
// FIXME: Flag change is required when deploying the collection module.
42-
localCacheEnabled: false,
41+
localCacheEnabled: true,
4342
});
4443
if (customApiHost) params.customApiHost = customApiHost;
4544
if (customWebSocketHost) params.customWebSocketHost = customWebSocketHost;

src/modules/App/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ export default function App(props: AppProps) {
100100
isTypingIndicatorEnabledOnChannelList,
101101
isMessageReceiptStatusEnabledOnChannelList,
102102
isUserIdUsedForNickname = true,
103-
// FIXME: Flag change is required when deploying the collection module.
104-
enableLegacyChannelModules = true,
103+
enableLegacyChannelModules = false,
105104
} = props;
106105
const [currentChannel, setCurrentChannel] = useState(null);
107106

src/modules/ChannelList/components/ChannelListHeader/index.scss

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/modules/ChannelList/components/ChannelListUI/channel-list-ui.scss

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 43 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './channel-list-ui.scss';
2-
31
import React from 'react';
42
import type { GroupChannel } from '@sendbird/chat/groupChannel';
53
import ChannelPreview from '../ChannelPreview';
@@ -10,32 +8,22 @@ import * as channelListActions from '../../dux/actionTypes';
108
import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext';
119
import { GroupChannelListUIView } from '../../../GroupChannelList/components/GroupChannelListUI/GroupChannelListUIView';
1210
import AddChannel from '../AddChannel';
11+
import { GroupChannelListItemBasicProps } from '../../../GroupChannelList/components/GroupChannelListItem/GroupChannelListItemView';
1312

14-
interface RenderChannelPreviewProps {
15-
channel: GroupChannel;
16-
onLeaveChannel(channel: GroupChannel, onLeaveChannelCb?: (channel: GroupChannel, error?: null) => void): void;
13+
interface ChannelPreviewProps extends Omit<GroupChannelListItemBasicProps, 'onLeaveChannel'> {
14+
onLeaveChannel(channel?: GroupChannel, onLeaveChannelCb?: (channel: GroupChannel, error?: null) => void): Promise<void>;
1715
}
1816

1917
export interface ChannelListUIProps {
20-
renderChannelPreview?: (
21-
props: RenderChannelPreviewProps
22-
) => React.ReactElement;
18+
renderChannelPreview?: (props: ChannelPreviewProps) => React.ReactElement;
2319
renderHeader?: (props: void) => React.ReactElement;
2420
renderPlaceHolderError?: (props: void) => React.ReactElement;
2521
renderPlaceHolderLoading?: (props: void) => React.ReactElement;
2622
renderPlaceHolderEmptyList?: (props: void) => React.ReactElement;
2723
}
2824

29-
const ChannelListUI: React.FC<ChannelListUIProps> = (
30-
props: ChannelListUIProps,
31-
) => {
32-
const {
33-
renderHeader,
34-
renderChannelPreview,
35-
renderPlaceHolderError,
36-
renderPlaceHolderLoading,
37-
renderPlaceHolderEmptyList,
38-
} = props;
25+
const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps) => {
26+
const { renderHeader, renderChannelPreview, renderPlaceHolderError, renderPlaceHolderLoading, renderPlaceHolderEmptyList } = props;
3927

4028
const {
4129
onThemeChange,
@@ -56,63 +44,53 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (
5644
const renderListItem = (props: { item: GroupChannel; index: number }) => {
5745
const { item: channel, index } = props;
5846

59-
const onLeaveChannel: RenderChannelPreviewProps['onLeaveChannel'] = (channel, cb) => {
60-
logger.info('ChannelList: Leaving channel', channel);
61-
channel
62-
.leave()
63-
.then((res) => {
64-
logger.info('ChannelList: Leaving channel success', res);
65-
if (cb && typeof cb === 'function') cb(channel, null);
66-
67-
channelListDispatcher({
68-
type: channelListActions.LEAVE_CHANNEL_SUCCESS,
69-
payload: channel.url,
70-
});
71-
})
72-
.catch((err) => {
73-
logger.error('ChannelList: Leaving channel failed', err);
74-
if (cb && typeof cb === 'function') cb(channel, err);
47+
const previewProps: ChannelPreviewProps = {
48+
channel,
49+
tabIndex: index,
50+
isSelected: channel?.url === currentChannel?.url,
51+
isTyping: typingChannels?.some(({ url }) => url === channel?.url),
52+
renderChannelAction: (props) => <ChannelPreviewAction {...props} />,
53+
onClick() {
54+
if (!isOnline && !sdk?.isCacheEnabled) {
55+
logger.warning('ChannelList: Inactivated clicking channel item during offline.');
56+
return;
57+
}
58+
logger.info('ChannelList: Clicked on channel:', channel);
59+
channelListDispatcher({
60+
type: channelListActions.SET_CURRENT_CHANNEL,
61+
payload: channel,
7562
});
76-
};
63+
},
64+
async onLeaveChannel(channel?: GroupChannel, cb?: (channel: GroupChannel, error?: null) => void) {
65+
logger.info('ChannelList: Leaving channel', channel);
66+
if (channel) {
67+
try {
68+
const response = await channel.leave();
69+
70+
logger.info('ChannelList: Leaving channel success', response);
71+
if (cb && typeof cb === 'function') cb(channel, null);
7772

78-
const onClickChannel = () => {
79-
if (!isOnline && !sdk?.isCacheEnabled) {
80-
logger.warning('ChannelList: Inactivated clicking channel item during offline.');
81-
return;
82-
}
83-
logger.info('ChannelList: Clicked on channel:', channel);
84-
channelListDispatcher({
85-
type: channelListActions.SET_CURRENT_CHANNEL,
86-
payload: channel,
87-
});
73+
channelListDispatcher({
74+
type: channelListActions.LEAVE_CHANNEL_SUCCESS,
75+
payload: channel.url,
76+
});
77+
} catch (err) {
78+
logger.error('ChannelList: Leaving channel failed', err);
79+
if (cb && typeof cb === 'function') cb(channel, err);
80+
}
81+
}
82+
},
8883
};
8984

9085
if (renderChannelPreview) {
9186
return (
92-
<div key={channel?.url} onClick={onClickChannel}>
93-
{renderChannelPreview({ channel, onLeaveChannel })}
87+
<div key={channel?.url} onClick={previewProps.onClick}>
88+
{renderChannelPreview(previewProps)}
9489
</div>
9590
);
9691
}
9792

98-
return (
99-
<ChannelPreview
100-
key={channel?.url}
101-
tabIndex={index}
102-
onClick={onClickChannel}
103-
channel={channel}
104-
onLeaveChannel={() => onLeaveChannel(channel, null)}
105-
isActive={channel?.url === currentChannel?.url}
106-
isTyping={typingChannels?.some(({ url }) => url === channel?.url)}
107-
renderChannelAction={() => (
108-
<ChannelPreviewAction
109-
channel={channel}
110-
disabled={!isOnline}
111-
onLeaveChannel={() => onLeaveChannel(channel, null)}
112-
/>
113-
)}
114-
/>
115-
);
93+
return <ChannelPreview key={channel?.url} {...previewProps} />;
11694
};
11795

11896
return (

src/modules/ChannelList/components/ChannelPreview/channel-preview.scss

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)