Skip to content

Commit ebc1768

Browse files
authored
[UK-940] Bugfix: Add checking current channel condition and has separator (#13)
- Add a condition checking currentChannelUrl before getChannel - Add params to renderChatItem with hasSeparator and menuDisabled
1 parent bf89dc4 commit ebc1768

File tree

8 files changed

+25
-20
lines changed

8 files changed

+25
-20
lines changed

src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ interface RenderChatItemProps {
322322
emojiContainer: EmojiContainer;
323323
chainTop: boolean;
324324
chainBottom: boolean;
325+
hasSeparator: boolean;
326+
menuDisabled: boolean;
325327
}
326328
interface RenderChatHeaderProps {
327329
channel: Sendbird.GroupChannel;

src/smart-components/ChannelList/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function ChannelList(props) {
137137
}
138138

139139
useEffect(() => {
140-
if (!sdk || !sdk.GroupChannel) { return; }
140+
if (!sdk || !sdk.GroupChannel || !currentChannel) { return; }
141141
sdk.GroupChannel.getChannel(currentChannel, (groupChannel) => {
142142
if (groupChannel) {
143143
onChannelSelect(groupChannel);

src/smart-components/Conversation/components/ConversationScroll.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export default class ConversationScroll extends Component {
133133
const previousMessageCreatedAt = previousMessage && previousMessage.createdAt;
134134
const currentCreatedAt = m.createdAt;
135135
// https://stackoverflow.com/a/41855608
136-
const hasSeperator = !(previousMessageCreatedAt && (
136+
const hasSeparator = !(previousMessageCreatedAt && (
137137
isSameDay(currentCreatedAt, previousMessageCreatedAt)
138138
));
139139
if (renderChatItem) {
@@ -153,6 +153,8 @@ export default class ConversationScroll extends Component {
153153
emojiContainer,
154154
chainTop,
155155
chainBottom,
156+
hasSeparator,
157+
menuDisabled: disabled,
156158
})
157159
}
158160
</div>
@@ -175,7 +177,7 @@ export default class ConversationScroll extends Component {
175177
emojiAllMap={emojiAllMap}
176178
emojiContainer={emojiContainer}
177179
editDisabled={editDisabled}
178-
hasSeperator={hasSeperator}
180+
hasSeparator={hasSeparator}
179181
chainBottom={chainBottom}
180182
updateMessage={updateMessage}
181183
deleteMessage={deleteMessage}

src/smart-components/Conversation/components/MessageHOC.jsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function MessageHoc({
1919
userId,
2020
disabled,
2121
editDisabled,
22-
hasSeperator,
22+
hasSeparator,
2323
deleteMessage,
2424
updateMessage,
2525
resendMessage,
@@ -59,7 +59,8 @@ export default function MessageHoc({
5959
const RenderedMessage = useMemo(() => {
6060
if (renderCustomMessage) {
6161
return renderCustomMessage(message, currentGroupChannel, chainTop, chainBottom);
62-
// Let's change this to object type on next major version up
62+
// TODO: Let's change this to object type on next major version up
63+
// and add params 'hasSeparator' and 'menuDisabled'
6364
}
6465
return null;
6566
}, [message, message.message, renderCustomMessage]);
@@ -77,9 +78,9 @@ export default function MessageHoc({
7778
${isAnimated ? 'sendbird-msg-hoc__highlighted' : ''}
7879
`}
7980
>
80-
{/* date-seperator */}
81+
{/* date-separator */}
8182
{
82-
hasSeperator && (
83+
hasSeparator && (
8384
<DateSeparator>
8485
<Label type={LabelTypography.CAPTION_2} color={LabelColors.ONBACKGROUND_2}>
8586
{format(message.createdAt, 'MMMM dd, yyyy')}
@@ -115,9 +116,9 @@ export default function MessageHoc({
115116
`}
116117
style={{ marginBottom: '2px' }}
117118
>
118-
{/* date-seperator */}
119+
{/* date-separator */}
119120
{
120-
hasSeperator && (
121+
hasSeparator && (
121122
<DateSeparator>
122123
<Label type={LabelTypography.CAPTION_2} color={LabelColors.ONBACKGROUND_2}>
123124
{format(message.createdAt, 'MMMM dd, yyyy')}
@@ -179,7 +180,7 @@ MessageHoc.propTypes = {
179180
isFileMessage: PropTypes.func,
180181
isAdminMessage: PropTypes.func,
181182
isUserMessage: PropTypes.func,
182-
isDateSeperator: PropTypes.func,
183+
isDateseparator: PropTypes.func,
183184
// should be a number, but there's a bug in SDK shich returns string
184185
messageId: PropTypes.number,
185186
type: PropTypes.string,
@@ -196,7 +197,7 @@ MessageHoc.propTypes = {
196197
]),
197198
renderCustomMessage: PropTypes.func,
198199
currentGroupChannel: PropTypes.shape({}),
199-
hasSeperator: PropTypes.bool,
200+
hasSeparator: PropTypes.bool,
200201
disabled: PropTypes.bool,
201202
editDisabled: PropTypes.bool,
202203
deleteMessage: PropTypes.func.isRequired,
@@ -223,7 +224,7 @@ MessageHoc.defaultProps = {
223224
renderCustomMessage: null,
224225
currentGroupChannel: {},
225226
message: {},
226-
hasSeperator: false,
227+
hasSeparator: false,
227228
disabled: false,
228229
highLightedMessageId: null,
229230
toggleReaction: () => { },

src/smart-components/OpenchannelConversation/components/MessageHOC.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface Props {
3333
userId: string;
3434
disabled: boolean;
3535
editDisabled: boolean;
36-
hasSeperator: boolean;
36+
hasSeparator: boolean;
3737
channel: OpenChannel;
3838
renderCustomMessage?: types.RenderCustomMessage,
3939
deleteMessage(message: types.ClientUserMessage | types.ClientFileMessage, callback?: () => void): void;
@@ -49,7 +49,7 @@ export default function MessageHoc({
4949
userId,
5050
disabled,
5151
editDisabled,
52-
hasSeperator,
52+
hasSeparator,
5353
channel,
5454
renderCustomMessage,
5555
deleteMessage,
@@ -109,9 +109,9 @@ export default function MessageHoc({
109109

110110
return (
111111
<div className="sendbird-msg-hoc sendbird-msg--scroll-ref">
112-
{/* date-seperator */}
112+
{/* date-separator */}
113113
{
114-
hasSeperator && (
114+
hasSeparator && (
115115
<DateSeparator>
116116
<Label type={LabelTypography.CAPTION_2} color={LabelColors.ONBACKGROUND_2}>
117117
{format(message.createdAt, 'MMMM dd, yyyy')}

src/smart-components/OpenchannelConversation/components/OpenchannelConversationScroll.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function OpenchannelConversationScroll(
112112
const previousMessageCreatedAt = previousMessage && previousMessage.createdAt;
113113
const currentCreatedAt = message.createdAt;
114114
// https://stackoverflow.com/a/41855608
115-
const hasSeperator = !(previousMessageCreatedAt && (
115+
const hasSeparator = !(previousMessageCreatedAt && (
116116
isSameDay(currentCreatedAt, previousMessageCreatedAt)
117117
));
118118

@@ -129,7 +129,7 @@ function OpenchannelConversationScroll(
129129
userId={user.userId}
130130
disabled={!isOnline}
131131
editDisabled={openchannel.isFrozen}
132-
hasSeperator={hasSeperator}
132+
hasSeparator={hasSeparator}
133133
chainTop={chainTop}
134134
chainBottom={chainBottom}
135135
deleteMessage={deleteMessage}

src/ui/UserProfile/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
}
3333

34-
.sendbird__user-profile-seperator {
34+
.sendbird__user-profile-separator {
3535
margin: 24px 0px;
3636
height: 1px;
3737
@include themed() {

src/ui/UserProfile/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function UserProfile({
7171
</section>
7272
)
7373
}
74-
<div className="sendbird__user-profile-seperator" />
74+
<div className="sendbird__user-profile-separator" />
7575
<section className="sendbird__user-profile-userId">
7676
<Label
7777
className="sendbird__user-profile-userId--label"

0 commit comments

Comments
 (0)