Skip to content

Commit 06b5ec6

Browse files
Merge pull request #402 from GetStream/vishal/slack-clone-fixes
Minor fixes/additions
2 parents 5b58e01 + db3b911 commit 06b5ec6

File tree

10 files changed

+111
-65
lines changed

10 files changed

+111
-65
lines changed

expo-package/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stream-chat-expo",
3-
"version": "2.0.0-beta.1",
3+
"version": "2.0.0-dev-sc.0",
44
"author": {
55
"company": "Stream.io Inc",
66
"name": "Stream.io Inc"
@@ -9,7 +9,7 @@
99
"main": "src/index.js",
1010
"types": "types/index.d.ts",
1111
"dependencies": {
12-
"stream-chat-react-native-core": "v2.0.0-beta.1"
12+
"stream-chat-react-native-core": "v2.0.0-dev-sc.0"
1313
},
1414
"peerDependencies": {
1515
"expo": "^39.0.0",

native-package/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stream-chat-react-native",
3-
"version": "2.0.0-beta.1",
3+
"version": "2.0.0-dev-sc.0",
44
"author": {
55
"company": "Stream.io Inc",
66
"name": "Stream.io Inc"
@@ -10,7 +10,7 @@
1010
"types": "types/index.d.ts",
1111
"dependencies": {
1212
"es6-symbol": "^3.1.3",
13-
"stream-chat-react-native-core": "v2.0.0-beta.1"
13+
"stream-chat-react-native-core": "v2.0.0-dev-sc.0"
1414
},
1515
"peerDependencies": {
1616
"@react-native-community/netinfo": ">=2.0.7",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stream-chat-react-native-core",
3-
"version": "2.0.0-beta.1",
3+
"version": "2.0.0-dev-sc.0",
44
"author": {
55
"company": "Stream.io Inc",
66
"name": "Stream.io Inc"

src/components/Message/MessageSimple/MessageActionSheet.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
66
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
77
import { styled } from '../../../styles/styledComponents';
88
import { MESSAGE_ACTIONS } from '../../../utils/utils';
9+
import type { Message as InsertDatesMessage } from '../../MessageList/utils/insertDates';
10+
import type {
11+
DefaultAttachmentType,
12+
DefaultChannelType,
13+
DefaultCommandType,
14+
DefaultEventType,
15+
DefaultMessageType,
16+
DefaultReactionType,
17+
DefaultUserType,
18+
UnknownType,
19+
} from '../../../types/types';
20+
import type { Reaction } from 'src/components/Reaction/ReactionList';
921

1022
const ActionSheetButtonContainer = styled.View`
1123
align-items: center;
@@ -62,7 +74,15 @@ export type ActionSheetStyles = {
6274
wrapper?: StyleProp<ViewStyle>;
6375
};
6476

65-
export type MessageActionSheetProps = {
77+
export type MessageActionSheetProps<
78+
At extends UnknownType = DefaultAttachmentType,
79+
Ch extends UnknownType = DefaultChannelType,
80+
Co extends string = DefaultCommandType,
81+
Ev extends UnknownType = DefaultEventType,
82+
Me extends UnknownType = DefaultMessageType,
83+
Re extends UnknownType = DefaultReactionType,
84+
Us extends UnknownType = DefaultUserType
85+
> = {
6686
/**
6787
* Handler to delete a current message
6888
*/
@@ -72,6 +92,8 @@ export type MessageActionSheetProps = {
7292
* The `editing` prop is used by the MessageInput component to switch to edit mode.
7393
*/
7494
handleEdit: () => void;
95+
handleReaction: (reactionType: string) => Promise<void>;
96+
message: InsertDatesMessage<At, Ch, Co, Ev, Me, Re, Us>;
7597
/**
7698
* Function that opens the reaction picker
7799
*/
@@ -97,6 +119,7 @@ export type MessageActionSheetProps = {
97119
* React useState hook setter function that toggles action sheet visibility
98120
*/
99121
setActionSheetVisible: React.Dispatch<React.SetStateAction<boolean>>;
122+
supportedReactions: Reaction[];
100123
/**
101124
* Style object for action sheet (used to style message actions)
102125
* Supported styles: https://github.com/beefe/react-native-actionsheet/blob/master/lib/styles.js

src/components/Message/MessageSimple/MessageContent.tsx

Lines changed: 66 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export type ForwardedMessageProps<
146146
* e.g., user avatar (to which message belongs to) is only showed for last (bottom) message in group.
147147
*/
148148
groupStyles: GroupType[];
149+
disabled?: boolean;
149150
/**
150151
* Custom message footer component
151152
*/
@@ -161,6 +162,7 @@ export type ForwardedMessageProps<
161162
MessageReplies?: React.ComponentType<
162163
MessageRepliesProps<At, Ch, Co, Ev, Me, Re, Us>
163164
>;
165+
textBeforeAttachments?: boolean;
164166
};
165167

166168
/**
@@ -229,9 +231,20 @@ export const MessageContent = <
229231
showActionSheet,
230232
supportedReactions = emojiData,
231233
threadList,
234+
textBeforeAttachments = false,
235+
disabled: disabledFromProps,
232236
} = props;
233237

234-
const { disabled } = useChannelContext<At, Ch, Co, Ev, Me, Re, Us>();
238+
const { disabled: disabledFromContext } = useChannelContext<
239+
At,
240+
Ch,
241+
Co,
242+
Ev,
243+
Me,
244+
Re,
245+
Us
246+
>();
247+
const disabled = disabledFromProps || disabledFromContext;
235248
const {
236249
Attachment: ContextAttachment,
237250
Message,
@@ -344,6 +357,53 @@ export const MessageContent = <
344357
return message.created_at;
345358
};
346359

360+
const renderAttachments = () => (
361+
<>
362+
{Array.isArray(message.attachments) &&
363+
message.attachments.map((attachment, index) => {
364+
// We handle files separately
365+
if (
366+
attachment.type === 'file' ||
367+
(attachment.type === 'image' &&
368+
!attachment.title_link &&
369+
!attachment.og_scrape_url)
370+
) {
371+
return null;
372+
}
373+
374+
return (
375+
<Attachment<At>
376+
actionHandler={handleAction}
377+
alignment={alignment}
378+
attachment={attachment}
379+
AttachmentActions={AttachmentActions}
380+
Card={Card}
381+
CardCover={CardCover}
382+
CardFooter={CardFooter}
383+
CardHeader={CardHeader}
384+
FileAttachment={FileAttachment}
385+
Giphy={Giphy}
386+
key={`${message.id}-${index}`}
387+
UrlPreview={UrlPreview}
388+
/>
389+
);
390+
})}
391+
{files.length > 0 && (
392+
<FileAttachmentGroup<At>
393+
alignment={alignment}
394+
AttachmentActions={AttachmentActions}
395+
AttachmentFileIcon={AttachmentFileIcon}
396+
FileAttachment={FileAttachment}
397+
files={files}
398+
handleAction={handleAction}
399+
messageId={message.id}
400+
/>
401+
)}
402+
{images.length > 0 && (
403+
<Gallery<At> alignment={alignment} images={images} />
404+
)}
405+
</>
406+
);
347407
return (
348408
<MessageContentProvider value={context}>
349409
<Container
@@ -401,49 +461,7 @@ export const MessageContent = <
401461
{MessageHeader && <MessageHeader testID='message-header' {...props} />}
402462
{/* TODO: Look at this in production: Reason for collapsible: https://github.com/facebook/react-native/issues/12966 */}
403463
<ContainerInner alignment={alignment} collapsable={false}>
404-
{Array.isArray(message.attachments) &&
405-
message.attachments.map((attachment, index) => {
406-
// We handle files separately
407-
if (
408-
attachment.type === 'file' ||
409-
(attachment.type === 'image' &&
410-
!attachment.title_link &&
411-
!attachment.og_scrape_url)
412-
) {
413-
return null;
414-
}
415-
416-
return (
417-
<Attachment<At>
418-
actionHandler={handleAction}
419-
alignment={alignment}
420-
attachment={attachment}
421-
AttachmentActions={AttachmentActions}
422-
Card={Card}
423-
CardCover={CardCover}
424-
CardFooter={CardFooter}
425-
CardHeader={CardHeader}
426-
FileAttachment={FileAttachment}
427-
Giphy={Giphy}
428-
key={`${message.id}-${index}`}
429-
UrlPreview={UrlPreview}
430-
/>
431-
);
432-
})}
433-
{files.length > 0 && (
434-
<FileAttachmentGroup<At>
435-
alignment={alignment}
436-
AttachmentActions={AttachmentActions}
437-
AttachmentFileIcon={AttachmentFileIcon}
438-
FileAttachment={FileAttachment}
439-
files={files}
440-
handleAction={handleAction}
441-
messageId={message.id}
442-
/>
443-
)}
444-
{images.length > 0 && (
445-
<Gallery<At> alignment={alignment} images={images} />
446-
)}
464+
{!textBeforeAttachments && renderAttachments()}
447465
<MessageTextContainer<At, Ch, Co, Ev, Me, Re, Us>
448466
alignment={alignment}
449467
disabled={message.status === 'failed' || message.type === 'error'}
@@ -456,6 +474,7 @@ export const MessageContent = <
456474
MessageText={MessageText}
457475
openThread={onOpenThread}
458476
/>
477+
{textBeforeAttachments && renderAttachments()}
459478
</ContainerInner>
460479
{repliesEnabled && (
461480
<MessageReplies<At, Ch, Co, Ev, Me, Re, Us>
@@ -484,13 +503,16 @@ export const MessageContent = <
484503
canEditMessage={canEditMessage}
485504
handleDelete={handleDelete}
486505
handleEdit={handleEdit}
506+
handleReaction={handleReaction}
507+
message={message}
487508
messageActions={messageActions}
488509
openReactionPicker={openReactionPicker}
489510
openThread={onOpenThread}
490511
reactionsEnabled={reactionsEnabled}
491512
ref={actionSheetRef}
492513
repliesEnabled={repliesEnabled}
493514
setActionSheetVisible={setActionSheetVisible}
515+
supportedReactions={emojiData}
494516
threadList={threadList}
495517
/>
496518
)}

src/components/Message/MessageSimple/MessageSimple.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ export type MessageSimpleProps<
358358
icon: string;
359359
id: string;
360360
}[];
361+
textBeforeAttachment?: boolean;
361362
/**
362363
* Custom UI component to display enriched url preview.
363364
* Defaults to https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Card.tsx

src/components/Message/MessageSimple/utils/renderText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const renderText = <
7676

7777
for (const urlInfo of urls) {
7878
const displayLink = truncate(urlInfo.encoded.replace(/^(www\.)/, ''), {
79-
length: 20,
79+
length: 200,
8080
omission: '...',
8181
});
8282
const markdown = `[${displayLink}](${urlInfo.protocol}${urlInfo.encoded})`;

src/components/MessageList/TypingIndicator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type {
2222
} from '../../types/types';
2323

2424
const Container = styled.View`
25-
align-items: center;
25+
align-items: flex-end;
2626
flex-direction: row;
2727
justify-content: flex-start;
2828
${({ theme }) => theme.typingIndicator.container.css};
@@ -70,7 +70,7 @@ export const TypingIndicator = <
7070
image={user.image}
7171
key={`${user.id}${idx}`}
7272
name={user.name || user.id}
73-
size={24}
73+
size={20}
7474
testID={`typing-avatar-${idx}`}
7575
/>
7676
))}

src/components/MessageList/__tests__/__snapshots__/TypingIndicator.test.js.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
55
style={
66
Array [
77
Object {
8-
"alignItems": "center",
8+
"alignItems": "flex-end",
99
"flexDirection": "row",
1010
"justifyContent": "flex-start",
1111
},
@@ -26,7 +26,7 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
2626
accessibilityLabel="initials"
2727
onError={[Function]}
2828
resizeMethod="resize"
29-
size={24}
29+
size={20}
3030
source={
3131
Object {
3232
"uri": "https://i.imgur.com/SLx06PP.png",
@@ -35,9 +35,9 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
3535
style={
3636
Array [
3737
Object {
38-
"borderRadius": 12,
39-
"height": 24,
40-
"width": 24,
38+
"borderRadius": 10,
39+
"height": 20,
40+
"width": 20,
4141
},
4242
]
4343
}
@@ -57,7 +57,7 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
5757
accessibilityLabel="initials"
5858
onError={[Function]}
5959
resizeMethod="resize"
60-
size={24}
60+
size={20}
6161
source={
6262
Object {
6363
"uri": "https://i.imgur.com/T68W8nR_d.webp?maxwidth=728&fidelity=grand",
@@ -66,9 +66,9 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
6666
style={
6767
Array [
6868
Object {
69-
"borderRadius": 12,
70-
"height": 24,
71-
"width": 24,
69+
"borderRadius": 10,
70+
"height": 20,
71+
"width": 20,
7272
},
7373
]
7474
}

src/components/Thread/Thread.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ export const Thread = <
171171
const headerComponent = (
172172
<>
173173
<DefaultMessage<At, Ch, Co, Ev, Me, Re, Us>
174-
{...additionalParentMessageProps}
175174
groupStyles={['single']}
176175
message={thread}
177176
Message={Message}
178177
threadList
178+
{...additionalParentMessageProps}
179179
/>
180180
<NewThread>
181181
<NewThreadText>{t('Start of a new thread')}</NewThreadText>
@@ -186,15 +186,15 @@ export const Thread = <
186186
return (
187187
<React.Fragment key={`thread-${thread.id}-${channel?.cid || ''}`}>
188188
<MessageList<At, Ch, Co, Ev, Me, Re, Us>
189-
{...additionalMessageListProps}
190189
HeaderComponent={headerComponent}
191190
Message={Message}
192191
threadList
192+
{...additionalMessageListProps}
193193
/>
194194
<MessageInput<At, Ch, Co, Ev, Me, Re, Us>
195-
{...additionalMessageInputProps}
196195
additionalTextInputProps={{ autoFocus, editable: !disabled }}
197196
parent_id={thread.id as StreamMessage<At, Me, Us>['parent_id']}
197+
{...additionalMessageInputProps}
198198
/>
199199
</React.Fragment>
200200
);

0 commit comments

Comments
 (0)