Skip to content

Commit 16fcc50

Browse files
authored
Add typing indicator and message status into the channel preview (#145)
App & SendbirdProvider * Add props * isTypingIndicatorEnabledOnChannelList * isMessageReceiptStatusEnabledOnChannelList Channel List * Add props * isTypingIndicatorEnabled * isMessageReceiptStatusEnabled * Add typing indicator into the Channel Preview component * Add message status into the Channel Preview component
1 parent ae6ac39 commit 16fcc50

File tree

15 files changed

+166
-28
lines changed

15 files changed

+166
-28
lines changed

src/index.d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ interface SendBirdProviderProps {
7171
config?: SendBirdProviderConfig;
7272
stringSet?: Record<string, string>;
7373
colorSet?: Record<string, string>;
74-
isMentionEnabled?: boolean;
7574
imageCompression?: {
7675
compressionRate?: number,
7776
resizingWidth?: number | string,
7877
resizingHeight?: number | string,
7978
};
79+
isMentionEnabled?: boolean;
80+
isTypingIndicatorEnabledOnChannelList?: boolean;
81+
isMessageReceiptStatusEnabledOnChannelList?: boolean;
8082
}
8183

8284
interface SendBirdStateConfig {
@@ -102,6 +104,8 @@ interface SendBirdStateConfig {
102104
resizingWidth?: number | string,
103105
resizingHeight?: number | string,
104106
};
107+
isTypingIndicatorEnabledOnChannelList?: boolean;
108+
isMessageReceiptStatusEnabledOnChannelList?: boolean;
105109
}
106110
export interface SdkStore {
107111
error: boolean;
@@ -262,6 +266,9 @@ interface AppProps {
262266
};
263267
replyType?: ReplyType;
264268
disableAutoSelect?: boolean;
269+
isMentionEnabled?: boolean;
270+
isTypingIndicatorEnabledOnChannelList?: boolean;
271+
isMessageReceiptStatusEnabledOnChannelList?: boolean;
265272
}
266273

267274
interface ApplicationUserListQuery {
@@ -309,6 +316,9 @@ export interface ChannelListProviderProps {
309316
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode;
310317
disableUserProfile?: boolean;
311318
disableAutoSelect?: boolean;
319+
typingChannels?: Array<Sendbird.GroupChannel>;
320+
isTypingIndicatorEnabled?: boolean;
321+
isMessageReceiptStatusEnabled?: boolean;
312322
}
313323

314324
export interface ChannelListProviderInterface extends ChannelListProviderProps {
@@ -352,6 +362,7 @@ interface ChannelListHeaderInterface {
352362
interface ChannelPreviewInterface {
353363
channel: SendBird.GroupChannel;
354364
isActive?: boolean;
365+
isTyping?: boolean;
355366
onClick: () => void;
356367
renderChannelAction: (props: { channel: SendBird.GroupChannel }) => React.ReactNode;
357368
tabIndex: number;

src/lib/Sendbird.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export default function Sendbird(props) {
4242
imageCompression,
4343
useReaction,
4444
isMentionEnabled,
45+
isTypingIndicatorEnabledOnChannelList,
46+
isMessageReceiptStatusEnabledOnChannelList,
4547
} = props;
4648

4749
const {
@@ -174,6 +176,8 @@ export default function Sendbird(props) {
174176
maxMentionCount: userMention?.maxMentionCount || 10,
175177
maxSuggestionCount: userMention?.maxSuggestionCount || 15,
176178
},
179+
isTypingIndicatorEnabledOnChannelList,
180+
isMessageReceiptStatusEnabledOnChannelList,
177181
},
178182
}}
179183
>
@@ -231,6 +235,8 @@ Sendbird.propTypes = {
231235
PropTypes.string,
232236
]),
233237
}),
238+
isTypingIndicatorEnabledOnChannelList: PropTypes.bool,
239+
isMessageReceiptStatusEnabledOnChannelList: PropTypes.bool,
234240
};
235241

236242
Sendbird.defaultProps = {
@@ -249,4 +255,6 @@ Sendbird.defaultProps = {
249255
imageCompression: {},
250256
useReaction: true,
251257
isMentionEnabled: false,
258+
isTypingIndicatorEnabledOnChannelList: false,
259+
isMessageReceiptStatusEnabledOnChannelList: false,
252260
};

src/lib/SendbirdState.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ interface SendBirdStateConfig {
5252
resizingWidth?: number | string,
5353
resizingHeight?: number | string,
5454
};
55+
isTypingIndicatorEnabledOnChannelList?: boolean;
56+
isMessageReceiptStatusEnabledOnChannelList?: boolean;
5557
}
5658

5759
export interface SdkStore {

src/lib/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export interface SendBirdProviderProps {
2424
resizingWidth?: number | string,
2525
resizingHeight?: number | string,
2626
};
27+
isTypingIndicatorEnabledOnChannelList?: boolean;
28+
isMessageReceiptStatusEnabledOnChannelList?: boolean;
2729
}
2830

2931
interface SendBirdStateConfig {
@@ -49,6 +51,8 @@ interface SendBirdStateConfig {
4951
resizingWidth?: number | string,
5052
resizingHeight?: number | string,
5153
};
54+
isTypingIndicatorEnabledOnChannelList?: boolean;
55+
isMessageReceiptStatusEnabledOnChannelList?: boolean;
5256
}
5357
export interface SdkStore {
5458
error: boolean;

src/smart-components/App/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export default function App(props) {
3939
onProfileEditSuccess,
4040
imageCompression,
4141
disableAutoSelect,
42+
isTypingIndicatorEnabledOnChannelList,
43+
isMessageReceiptStatusEnabledOnChannelList,
4244
} = props;
4345
const [currentChannelUrl, setCurrentChannelUrl] = useState(null);
4446
const [showSettings, setShowSettings] = useState(false);
@@ -64,6 +66,8 @@ export default function App(props) {
6466
imageCompression={imageCompression}
6567
useReaction={useReaction}
6668
isMentionEnabled={isMentionEnabled}
69+
isTypingIndicatorEnabledOnChannelList={isTypingIndicatorEnabledOnChannelList}
70+
isMessageReceiptStatusEnabledOnChannelList={isMessageReceiptStatusEnabledOnChannelList}
6771
>
6872
<div className="sendbird-app__wrap">
6973
<div className="sendbird-app__channellist-wrap">
@@ -183,6 +187,8 @@ App.propTypes = {
183187
}),
184188
disableAutoSelect: PropTypes.bool,
185189
isMentionEnabled: PropTypes.bool,
190+
isTypingIndicatorEnabledOnChannelList: PropTypes.bool,
191+
isMessageReceiptStatusEnabledOnChannelList: PropTypes.bool,
186192
};
187193

188194
App.defaultProps = {
@@ -206,4 +212,6 @@ App.defaultProps = {
206212
colorSet: null,
207213
imageCompression: {},
208214
disableAutoSelect: false,
215+
isTypingIndicatorEnabledOnChannelList: false,
216+
isMessageReceiptStatusEnabledOnChannelList: false,
209217
};

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ export const Korean = () => fitPageSize(
210210
CHANNEL__MESSAGE_INPUT__PLACE_HOLDER__DISABLED: '입력이 불가능 합니다',
211211
CHANNEL__MESSAGE_INPUT__PLACE_HOLDER__MUTED: '음소거 되었습니다',
212212
}}
213+
isMentionEnabled
214+
isTypingIndicatorEnabledOnChannelList
215+
isMessageReceiptStatusEnabledOnChannelList
213216
/>
214217
);
215218

@@ -225,6 +228,8 @@ export const user1 = () => fitPageSize(
225228
queries={{}}
226229
replyType="QUOTE_REPLY"
227230
isMentionEnabled
231+
isTypingIndicatorEnabledOnChannelList
232+
isMessageReceiptStatusEnabledOnChannelList
228233
/>
229234
);
230235
export const user2 = () => fitPageSize(
@@ -244,6 +249,8 @@ export const user2 = () => fitPageSize(
244249
resizingHeight: '100px',
245250
}}
246251
isMentionEnabled
252+
isTypingIndicatorEnabledOnChannelList
253+
isMessageReceiptStatusEnabledOnChannelList
247254
/>
248255
);
249256
export const user3 = () => fitPageSize(
@@ -257,6 +264,8 @@ export const user3 = () => fitPageSize(
257264
profileUrl={addProfile}
258265
config={{ logLevel: 'all' }}
259266
replyType="QUOTE_REPLY"
267+
isTypingIndicatorEnabledOnChannelList
268+
isMessageReceiptStatusEnabledOnChannelList
260269
/>
261270
);
262271
export const user4 = () => fitPageSize(

src/smart-components/App/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ export default interface AppProps {
3434
};
3535
replyType?: ReplyType;
3636
disableAutoSelect?: boolean;
37+
isTypingIndicatorEnabledOnChannelList?: boolean;
38+
isMessageReceiptStatusEnabledOnChannelList?: boolean;
3739
}

src/smart-components/Channel/components/TypingIndicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface TypingIndicatorTextProps {
1111
members: SendBird.Member[];
1212
}
1313

14-
const TypingIndicatorText: React.FC<TypingIndicatorTextProps> = ({ members }: TypingIndicatorTextProps) => {
14+
export const TypingIndicatorText: React.FC<TypingIndicatorTextProps> = ({ members }: TypingIndicatorTextProps) => {
1515
const { stringSet } = useContext(LocalizationContext);
1616
if (!members || members.length === 0) {
1717
return '';

src/smart-components/ChannelList/components/ChannelListUI/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps)
5757
currentChannel,
5858
channelListDispatcher,
5959
channelSource,
60+
typingChannels,
6061
} = useChannelListContext();
6162

6263
const state = useSendbirdStateContext();
@@ -195,6 +196,7 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps)
195196
onClick={onClick}
196197
channel={channel}
197198
isActive={channel.url === currentChannel?.url}
199+
isTyping={typingChannels?.some(({ url }) => url === channel.url)}
198200
renderChannelAction={(() => (
199201
<ChannelPreviewAction
200202
disabled={!isOnline}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
margin-left: 4px;
6868
margin-bottom: 4px;
6969
white-space: nowrap;
70+
&.sendbird-message-status {
71+
max-width: 74px;
72+
justify-content: flex-end;
73+
}
7074
}
7175
}
7276

0 commit comments

Comments
 (0)