Skip to content

Commit 014f4ac

Browse files
authored
Merge pull request #311 from GetStream/CRNS-120/Message
CRNS-120/Message
2 parents aef133b + 70390c9 commit 014f4ac

File tree

63 files changed

+5963
-4106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5963
-4106
lines changed

.eslintrc.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@
1616
"ecmaVersion": 2018,
1717
"sourceType": "module"
1818
},
19-
"plugins": ["babel", "markdown"],
19+
"plugins": [
20+
"babel",
21+
"markdown",
22+
"better-styled-components",
23+
"sort-destructure-keys"
24+
],
2025
"rules": {
2126
"array-callback-return": 2,
2227
"arrow-body-style": 2,
28+
"better-styled-components/sort-declarations-alphabetically": 0,
2329
"comma-dangle": 0,
2430
"babel/no-invalid-this": 2,
2531
"default-case": 2,
@@ -50,6 +56,10 @@
5056
"react/prop-types": 0,
5157
"require-await": 2,
5258
"semi": [1, "always"],
59+
"sort-destructure-keys/sort-destructure-keys": [
60+
2,
61+
{ "caseSensitive": false }
62+
],
5363
"sort-imports": [
5464
"error",
5565
{
@@ -120,12 +130,15 @@
120130
"markdown",
121131
"prettier",
122132
"react",
123-
"typescript-sort-keys"
133+
"typescript-sort-keys",
134+
"better-styled-components",
135+
"sort-destructure-keys"
124136
],
125137
"rules": {
126138
"@typescript-eslint/ban-ts-comment": 0,
127139
"array-callback-return": 2,
128140
"arrow-body-style": 2,
141+
"better-styled-components/sort-declarations-alphabetically": 0,
129142
"comma-dangle": 0,
130143
"babel/no-invalid-this": 2,
131144
"default-case": 2,
@@ -155,6 +168,10 @@
155168
"react/prop-types": 0,
156169
"require-await": 2,
157170
"semi": [1, "always"],
171+
"sort-destructure-keys/sort-destructure-keys": [
172+
2,
173+
{ "caseSensitive": false }
174+
],
158175
"sort-imports": [
159176
"error",
160177
{

CHANGELOG.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Changelog
22

3-
## [1.3.0] 2020-09-01 (UNPUBLISHED)
3+
## [1.3.0] 2020-09-11 (UNPUBLISHED)
44

55
**BREAKING CHANGES**
66

77
*ChannelList*
88

9-
- We converted the ChannelList component from a class to a function and abstracted the event listener logic into custom hooks. The default event handlers can still be overriden by providing custom prop functions to the ChannelList component. Custom logic can be provided for the following events:
9+
- We converted the ChannelList component from a class to a function and abstracted the event listener logic into custom hooks. The default event handlers can still be overridden by providing custom prop functions to the ChannelList component. Custom logic can be provided for the following events:
1010

1111
- `onAddedToChannel` overrides `notification.added_to_channel` default
1212
- `onChannelDeleted` overrides `channel.deleted` default
@@ -74,10 +74,20 @@
7474

7575
- All contexts are exported and any values can be accessed through a higher order component (ex: `withMessagesContext`) or the `useContext` hook (ex: `const { messages } = useContext(MessagesContext);`)
7676

77-
- Dropped support for deprecated props from MessageList component
77+
*Deprecated Props*
78+
79+
- We have removed support for the `MessageList` component's `onMessageTouch` prop. Since this prop no longer exists, we have also removed `dismissKeyboardOnMessageTouch`. Please use the `onPress` prop on the `MessageSimple` component to perform an action on touch of a message.
80+
81+
- We have removed support for the `Message` component's `readOnly` prop. Please use the `disabled` value from the `ChannelContext` instead.
82+
83+
- We have also dropped support for the following `MessageList` props:
7884
- `dateSeparator` (use DateSeparator instead)
7985
- `headerComponent` (use HeaderComponent instead)
8086

87+
*this Reference Removal*
88+
89+
- We have removed the `this` class component reference from the prop functions in `MessageSimple`. For example, if you wish to override the SDK's standard long press behavior on a message, the `onLongPress` function passed in to `MessageSimple` no longer takes the `this` component reference as it's first argument. The message and the event object become the first and second arguments, respectively.
90+
8191
## [1.2.0] 2020-08-21
8292

8393
**NO BREAKING CHANGES**

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@
9595
"anchorme": "^1.1.2",
9696
"babel-plugin-macros": "^2.8.0",
9797
"dayjs": "^1.8.32",
98-
"deep-equal": "^1.0.1",
99-
"deepmerge": "^3.2.0",
10098
"file-loader": "^3.0.1",
10199
"i18next": "^19.3.1",
102100
"lodash-es": "^4.17.11",
@@ -142,10 +140,12 @@
142140
"eslint": "^7.6.0",
143141
"eslint-config-prettier": "^6.11.0",
144142
"eslint-plugin-babel": "^5.3.0",
143+
"eslint-plugin-better-styled-components": "^1.1.2",
145144
"eslint-plugin-jest": "^23.20.0",
146145
"eslint-plugin-markdown": "^1.0.0",
147146
"eslint-plugin-prettier": "^3.1.4",
148147
"eslint-plugin-react": "^7.12.4",
148+
"eslint-plugin-sort-destructure-keys": "^1.3.5",
149149
"eslint-plugin-typescript-sort-keys": "^1.3.0",
150150
"husky": "^2.1.0",
151151
"jest": "^26.2.2",

src/components/Attachment/AttachmentActions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ const Container = styled.View`
1515
const ActionButton = styled(({ buttonStyle, ...rest }) => (
1616
<TouchableOpacity {...rest} />
1717
))`
18-
background-color: ${({ theme, buttonStyle }) =>
18+
background-color: ${({ buttonStyle, theme }) =>
1919
buttonStyle === 'primary'
2020
? theme.message.actions.button.primaryBackgroundColor
2121
: theme.message.actions.button.defaultBackgroundColor};
22-
border-color: ${({ theme, buttonStyle }) =>
22+
border-color: ${({ buttonStyle, theme }) =>
2323
buttonStyle === 'primary'
2424
? theme.message.actions.button.primaryBorderColor
2525
: theme.message.actions.button.defaultBorderColor};
@@ -33,7 +33,7 @@ const ActionButton = styled(({ buttonStyle, ...rest }) => (
3333
const ActionButtonText = styled(({ buttonStyle, ...rest }) => (
3434
<Text {...rest} />
3535
))`
36-
color: ${({ theme, buttonStyle }) =>
36+
color: ${({ buttonStyle, theme }) =>
3737
buttonStyle === 'primary'
3838
? theme.message.actions.buttonText.primaryColor
3939
: theme.message.actions.buttonText.defaultColor};
@@ -46,7 +46,7 @@ const ActionButtonText = styled(({ buttonStyle, ...rest }) => (
4646
*
4747
* @example ../docs/AttachmentActions.md
4848
*/
49-
const AttachmentActions = ({ actions, actionHandler, id }) => (
49+
const AttachmentActions = ({ actionHandler, actions, id }) => (
5050
<Container testID='attachment-actions'>
5151
{actions.map((action) => (
5252
<ActionButton

src/components/Attachment/FileAttachment.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const FileContainer = styled.View`
2828
`;
2929

3030
const FileDetails = styled.View`
31-
flex-direction: column;
3231
padding-left: 10px;
3332
${({ theme }) => theme.message.file.details.css}
3433
`;

src/components/Attachment/Gallery.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const GalleryContainer = styled.View`
3131
alignment === 'right' ? 16 : 2}px;
3232
flex-direction: row;
3333
flex-wrap: wrap;
34-
height: ${({ theme, length }) =>
34+
height: ${({ length, theme }) =>
3535
length >= 4
3636
? theme.message.gallery.doubleSize
3737
: length === 3
@@ -43,11 +43,11 @@ const GalleryContainer = styled.View`
4343
`;
4444

4545
const ImageContainer = styled.TouchableOpacity`
46-
height: ${({ theme, length }) =>
46+
height: ${({ length, theme }) =>
4747
length !== 3
4848
? theme.message.gallery.size
4949
: theme.message.gallery.halfSize}px;
50-
width: ${({ theme, length }) =>
50+
width: ${({ length, theme }) =>
5151
length !== 3
5252
? theme.message.gallery.size
5353
: theme.message.gallery.halfSize}px;
@@ -144,7 +144,11 @@ const Gallery = ({ alignment, images }) => {
144144

145145
return (
146146
<>
147-
<GalleryContainer alignment={alignment} length={galleryImages.length}>
147+
<GalleryContainer
148+
alignment={alignment}
149+
length={galleryImages.length}
150+
testID='image-multiple-container'
151+
>
148152
{galleryImages.slice(0, 4).map((image, i) => (
149153
<ImageContainer
150154
activeOpacity={0.8}
@@ -155,6 +159,7 @@ const Gallery = ({ alignment, images }) => {
155159
setViewerModalOpen(true);
156160
setViewerModalImageIndex(i);
157161
}}
162+
testID='image-multiple'
158163
{...additionalTouchableProps}
159164
>
160165
{i === 3 && galleryImages.length > 4 ? (

src/components/AutoCompleteInput/CommandsItem.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const CommandDescription = styled.Text`
1313
`;
1414

1515
const Container = styled.View`
16-
flex-direction: column;
1716
padding: 10px;
1817
${({ theme }) => theme.messageInput.suggestions.command.container.css}
1918
`;

src/components/Channel/Channel.js

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

259259
const sendMessageRequest = async (message) => {
260260
const {
261+
__html,
261262
attachments,
262263
created_at,
263-
__html,
264264
html,
265265
id,
266266
mentioned_users,

src/components/Channel/__tests__/Channel.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ describe('Channel', () => {
208208
const newMessages = [generateMessage()];
209209
renderComponent(
210210
{ channel },
211-
({ loadMore, messages: contextMessages, hasMore }) => {
211+
({ hasMore, loadMore, messages: contextMessages }) => {
212212
if (
213213
!contextMessages.find((message) => message.id === newMessages[0].id)
214214
) {
@@ -248,7 +248,7 @@ describe('Channel', () => {
248248

249249
renderComponent(
250250
{ channel },
251-
({ loadMore, loadingMore }) => {
251+
({ loadingMore, loadMore }) => {
252252
// return a promise that hasn't resolved yet, so loadMore will be stuck in the 'await' part of the function
253253
jest.spyOn(channel, 'query').mockImplementationOnce(() => queryPromise);
254254
loadMore();
@@ -302,7 +302,7 @@ describe('Channel', () => {
302302

303303
renderComponent(
304304
{ channel },
305-
({ removeMessage, messages: contextMessages }) => {
305+
({ messages: contextMessages, removeMessage }) => {
306306
if (contextMessages.length > 0) {
307307
// if there are messages passed as the context, remove them
308308
removeMessage(contextMessages[0]);

src/components/ChannelList/__tests__/ChannelList.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('ChannelList', () => {
178178
});
179179

180180
it('should move channel to top of the list by default', async () => {
181-
const { getByText, getByTestId, getAllByRole } = render(
181+
const { getAllByRole, getByTestId, getByText } = render(
182182
<Chat client={chatClient}>
183183
<ChannelList {...props} />
184184
</Chat>,
@@ -202,7 +202,7 @@ describe('ChannelList', () => {
202202
});
203203

204204
it('should not alter order if `lockChannelOrder` prop is true', async () => {
205-
const { getByText, getByTestId, getAllByRole } = render(
205+
const { getAllByRole, getByTestId, getByText } = render(
206206
<Chat client={chatClient}>
207207
<ChannelList {...props} lockChannelOrder={true} />
208208
</Chat>,
@@ -235,7 +235,7 @@ describe('ChannelList', () => {
235235
});
236236

237237
it('should move a channel to top of the list by default', async () => {
238-
const { getByTestId, getAllByRole } = render(
238+
const { getAllByRole, getByTestId } = render(
239239
<Chat client={chatClient}>
240240
<ChannelList {...props} />
241241
</Chat>,
@@ -293,7 +293,7 @@ describe('ChannelList', () => {
293293
});
294294

295295
it('should move a channel to top of the list by default', async () => {
296-
const { getByTestId, getAllByRole } = render(
296+
const { getAllByRole, getByTestId } = render(
297297
<Chat client={chatClient}>
298298
<ChannelList {...props} />
299299
</Chat>,

0 commit comments

Comments
 (0)