Skip to content

Commit 910b15d

Browse files
authored
[UK-965]Fix SENDING_MESSAGE_START payload mismatch (#18)
* Fix SENDING_MESSAGE_START payload mismatch * Fix CSS issue with render custom message
1 parent 22892d5 commit 910b15d

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sendbird-uikit",
3-
"version": "2.4.1",
3+
"version": "2.4.2-0",
44
"description": "React based UI kit for sendbird",
55
"main": "release/index.js",
66
"style": "release/dist/index.css",

src/smart-components/OpenchannelConversation/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const OpenchannelConversation = (props: Props): JSX.Element => {
202202
if (channel && (channelUrl === channel.url)) {
203203
messagesDispatcher({
204204
type: messageActionTypes.SENDING_MESSAGE_START,
205-
payload: message,
205+
payload: { message, channel },
206206
});
207207
}
208208
}));
@@ -212,7 +212,7 @@ export const OpenchannelConversation = (props: Props): JSX.Element => {
212212
if (channel && (channelUrl === channel.url)) {
213213
messagesDispatcher({
214214
type: messageActionTypes.SENDING_MESSAGE_SUCCEEDED,
215-
payload: message,
215+
payload: { message, channel },
216216
});
217217
}
218218
}));
@@ -306,11 +306,15 @@ export const OpenchannelConversation = (props: Props): JSX.Element => {
306306
{
307307
renderMessageInput
308308
? (
309-
renderMessageInput({
310-
channel: currentOpenChannel,
311-
user: user,
312-
disabled: disabled,
313-
})
309+
<div className="sendbird-openchannel-footer">
310+
{
311+
renderMessageInput({
312+
channel: currentOpenChannel,
313+
user: user,
314+
disabled: disabled,
315+
})
316+
}
317+
</div>
314318
)
315319
: (
316320
<MessageInputWrapper

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import Sendbird from '../../../lib/Sendbird';
33
import OpenchannelConversation from '../index';
44
import { MenuRoot } from '../../../ui/ContextMenu';
5+
import useSendbirdStateContext from '../../../hooks/useSendbirdStateContext';
6+
import sendbirdSelectors from '../../../lib/selectors';
57

68
export default { title: 'OpenChannel' };
79

@@ -26,6 +28,34 @@ export const defaultConversation = () => {
2628
);
2729
};
2830

31+
const CustomInput = (params) => {
32+
const { channel } = params;
33+
const [inputText, setInputText] = useState("");
34+
const context = useSendbirdStateContext();
35+
const sdk = sendbirdSelectors.getSdk(context);
36+
const sendUserMessage = sendbirdSelectors.getOpenChannelSendUserMessage(context);
37+
38+
return (
39+
<div>
40+
<input value={inputText} onChange={(event) => {
41+
setInputText(event.target.value);
42+
}}/>
43+
<button onClick={() => {
44+
const params = new sdk.UserMessageParams();
45+
params.message = inputText;
46+
sendUserMessage(channel.url, params)
47+
.then((message) => {
48+
console.log(message);
49+
setInputText("");
50+
})
51+
.catch((error) => {
52+
console.log(error.message);
53+
});
54+
}}>send</button>
55+
</div>
56+
);
57+
}
58+
2959
export const RenderCustomMessage = () => {
3060
return (
3161
<Sendbird
@@ -44,6 +74,9 @@ export const RenderCustomMessage = () => {
4474
)
4575
}
4676
}}
77+
renderMessageInput={(props) => {
78+
return (<CustomInput {...props} />);
79+
}}
4780
/>
4881
</div>
4982
<MenuRoot />

0 commit comments

Comments
 (0)