Skip to content

Commit a9e181c

Browse files
Merge pull request #334 from GetStream/vishal/slack-clone-bugs
Fixing issues found during testing of slack-clone
2 parents 6fabeed + 0b84683 commit a9e181c

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

src/components/AutoCompleteInput/AutoCompleteInput.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useRef, useState } from 'react';
1+
import React, { useContext, useEffect, useRef } from 'react';
22
import styled from '@stream-io/styled-components';
33
import PropTypes from 'prop-types';
44

@@ -43,8 +43,7 @@ const AutoCompleteInput = ({
4343
const { t } = useContext(TranslationContext);
4444

4545
const isTrackingStarted = useRef(false);
46-
47-
const [selectionEnd, setSelectionEnd] = useState(0);
46+
const selectionEnd = useRef(0);
4847

4948
useEffect(() => {
5049
handleChange(value, true);
@@ -72,7 +71,6 @@ const AutoCompleteInput = ({
7271
if (query !== queryCallback) {
7372
return;
7473
}
75-
7674
updateSuggestionsContext({
7775
data,
7876
onSelect: (item) => onSelectSuggestion({ item, trigger }),
@@ -94,7 +92,7 @@ const AutoCompleteInput = ({
9492
selection: { end },
9593
},
9694
}) => {
97-
setSelectionEnd(end);
95+
selectionEnd.current = end;
9896
};
9997

10098
const onSelectSuggestion = ({ item, trigger }) => {
@@ -104,7 +102,7 @@ const AutoCompleteInput = ({
104102
return;
105103
}
106104

107-
const textToModify = value.slice(0, selectionEnd);
105+
const textToModify = value.slice(0, selectionEnd.current);
108106

109107
const startOfTokenPosition = textToModify.search(
110108
/**
@@ -128,7 +126,7 @@ const AutoCompleteInput = ({
128126
stopTracking();
129127
onChange(value.replace(textToModify, modifiedText));
130128

131-
setSelectionEnd(newCaretPosition || 0);
129+
selectionEnd.current = newCaretPosition || 0;
132130

133131
if (triggerSettings[trigger].callback) {
134132
triggerSettings[trigger].callback(item);
@@ -190,12 +188,12 @@ const AutoCompleteInput = ({
190188
const handleSuggestions = (text) => {
191189
setTimeout(async () => {
192190
if (
193-
text.slice(selectionEnd - 1, selectionEnd) === ' ' &&
191+
text.slice(selectionEnd.current - 1, selectionEnd.current) === ' ' &&
194192
!isTrackingStarted.current
195193
) {
196194
stopTracking();
197195
} else if (!(await handleCommand(text))) {
198-
handleMentions({ selectionEnd, text });
196+
handleMentions({ selectionEnd: selectionEnd.current, text });
199197
}
200198
}, 100);
201199
};

src/components/Channel/Channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const Channel = (props) => {
194194

195195
const initChannel = async () => {
196196
let initError = false;
197-
197+
setError(false);
198198
if (!channel.initialized && channel.cid) {
199199
try {
200200
await channel.watch();

src/components/Message/MessageSimple/MessageContent.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,21 @@ const MessageContent = (props) => {
399399

400400
MessageContent.themePath = 'message.content';
401401

402+
MessageContent.defaultProps = {
403+
ActionSheet: DefaultActionSheet,
404+
enableLongPress: true,
405+
FileAttachment: DefaultFileAttachment,
406+
FileAttachmentGroup: DefaultFileAttachmentGroup,
407+
Gallery: DefaultGallery,
408+
hideReactionCount: false,
409+
hideReactionOwners: false,
410+
MessageReplies: DefaultMessageReplies,
411+
ReactionList: DefaultReactionList,
412+
reactionsEnabled: true,
413+
repliesEnabled: true,
414+
supportedReactions: emojiData,
415+
};
416+
402417
MessageContent.propTypes = {
403418
/**
404419
* Custom UI component for the action sheet that appears on long press of a Message.

src/components/Message/MessageSimple/MessageSimple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const MessageSimple = (props) => {
6262
...props,
6363
alignment,
6464
customMessageContent,
65-
groupStyles: hasReactions ? ['bottom'] : groupStyles,
65+
groupStyles: hasReactions && props.ReactionList ? ['bottom'] : groupStyles,
6666
};
6767

6868
return (

0 commit comments

Comments
 (0)