Skip to content

Commit 6360695

Browse files
authored
Merge pull request #1426 from GetStream/develop
Next release
2 parents f87b1a4 + b9cea84 commit 6360695

File tree

81 files changed

+2927
-1000
lines changed

Some content is hidden

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

81 files changed

+2927
-1000
lines changed

.github/workflows/check-pr.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint & Unit Tests
1+
name: Lint, Unit Tests, and Code Analysis
22

33
on:
44
pull_request:
@@ -13,6 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v2
16+
with:
17+
# Disabling shallow clone is recommended for improving relevancy of reporting
18+
fetch-depth: 0
1619
- name: Use Node.js ${{ matrix.node-version }}
1720
uses: actions/setup-node@v2
1821
with:
@@ -25,3 +28,16 @@ jobs:
2528
run: yarn lerna-workspaces run lint && cd docusaurus && npx prettier --check '**/*.mdx'
2629
- name: Test
2730
run: yarn test:unit
31+
- name: SonarCloud Scan
32+
uses: sonarsource/sonarcloud-github-action@master
33+
with:
34+
args: >
35+
-Dsonar.organization=getstream
36+
-Dsonar.projectKey=GetStream_stream-chat-react-native
37+
-Dsonar.javascript.lcov.reportPaths=./package/coverage/lcov.info
38+
-Dsonar.sources=package/src/
39+
-Dsonar.test.exclusions=**/__tests__/**
40+
-Dsonar.verbose=true
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
[![NPM](https://img.shields.io/npm/v/stream-chat-react-native.svg)](https://www.npmjs.com/package/stream-chat-react-native)
1212
[![Build Status](https://github.com/GetStream/stream-chat-react-native/workflows/test/badge.svg?branch=main)](https://github.com/GetStream/stream-chat-react-native/actions)
1313
[![Component Reference](https://img.shields.io/badge/docs-component%20reference-blue.svg)](https://getstream.io/chat/docs/sdk/reactnative)
14+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=GetStream_stream-chat-react-native&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=GetStream_stream-chat-react-native)
1415

1516
<img align="right" src="https://getstream.imgix.net/images/ios-chat-tutorial/[email protected]?auto=format,enhance" width="50%" />
1617

docusaurus/docs/reactnative/basics/getting_started.mdx

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This should be considered a primer before delving into the UI and Core Component
1616

1717
Your [environment should be setup](https://reactnative.dev/docs/environment-setup) and a project created prior to beginning the installation.
1818

19-
### Add dependencies
19+
### Add Required dependencies
2020

2121
Install the required packages in your React Native project.
2222

@@ -60,6 +60,7 @@ Most if not all of the required packages now support auto-linking so setup shoul
6060
- [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context)
6161
- [`react-native-share`](https://github.com/react-native-share/react-native-share)
6262
- [`react-native-svg`](https://github.com/react-native-svg/react-native-svg)
63+
- [`react-native-video`](https://github.com/react-native-video/react-native-video)
6364

6465
<Tabs
6566
defaultValue='yarn'
@@ -71,14 +72,14 @@ Most if not all of the required packages now support auto-linking so setup shoul
7172
<TabItem value='yarn'>
7273

7374
```bash
74-
yarn add @react-native-community/cameraroll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-haptic-feedback react-native-haptic-feedback react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-safe-area-context react-native-share react-native-svg
75+
yarn add @react-native-community/cameraroll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-haptic-feedback react-native-haptic-feedback react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-safe-area-context react-native-share react-native-svg react-native-video
7576
```
7677

7778
</TabItem>
7879
<TabItem value='npm'>
7980

8081
```bash
81-
npm install @react-native-community/cameraroll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-haptic-feedback react-native-haptic-feedback react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-safe-area-context react-native-share react-native-svg
82+
npm install @react-native-community/cameraroll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-haptic-feedback react-native-haptic-feedback react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-safe-area-context react-native-share react-native-svg react-native-video
8283
```
8384

8485
</TabItem>
@@ -157,6 +158,15 @@ If you are planning to use file picker functionality, make sure you enable iClou
157158

158159
:::
159160

161+
### Add Optional Dependencies
162+
163+
- `react-native-video` - [additional installation steps](https://github.com/react-native-video/react-native-video/blob/master/API.md#installation)
164+
165+
> Available in stream-chat-react-native >= v4.7.0
166+
167+
Installing this package allows you to play the video files/attachments in the chat. Otherwise by default, video files will be opened in default
168+
browser of the device.
169+
160170
### AndroidX Support
161171

162172
> AndroidX is a major step forward in the Android ecosystem, and the old support library artifacts are being deprecated.
@@ -170,9 +180,67 @@ But an awesome tool named [jetifier](https://github.com/mikehardy/jetifier) is q
170180

171181
## Expo Installation
172182

173-
Stream Chat for React Native is set up for parity on Expo, expo requires a different set of dependencies than bare React Native, in your project directory run:
183+
Stream Chat for React Native is set up for parity on Expo, expo requires a different set of dependencies than bare React Native, in your project directory run.
184+
185+
### Add Required Dependencies
174186

175187
```bash
176188
expo install stream-chat-expo
177-
expo install @react-native-community/netinfo expo-document-picker expo-file-system expo-haptics expo-image-manipulator expo-image-picker expo-media-library expo-sharing react-native-gesture-handler react-native-reanimated react-native-safe-area-context react-native-svg
189+
expo install @react-native-community/netinfo expo-document-picker expo-file-system expo-haptics expo-image-manipulator expo-image-picker expo-media-library expo-sharing react-native-gesture-handler react-native-reanimated react-native-safe-area-context react-native-svg expo-av
178190
```
191+
192+
### Additional Steps
193+
194+
For some of the packages listed below, there are additional steps required to setup the package:
195+
196+
- `react-native-reanimated` - [additional installation steps](https://docs.expo.dev/versions/latest/sdk/reanimated/#installation)
197+
198+
Add Reanimated's babel plugin to your babel.config.js:
199+
200+
```js
201+
module.exports = {
202+
...
203+
plugins: [
204+
...
205+
'react-native-reanimated/plugin',
206+
],
207+
};
208+
```
209+
210+
- `react-native-gesture-handler` - [additional installation steps](https://docs.expo.dev/versions/latest/sdk/gesture-handler/#api)
211+
212+
RNGH requires the package to be imported at the **top of the entry file** before anything else, this is usually your `App.js` or `index.js` file.
213+
214+
```tsx
215+
import 'react-native-gesture-handler';
216+
import { AppRegistry } from 'react-native';
217+
218+
import App from './App';
219+
import { name as appName } from './app.json';
220+
221+
AppRegistry.registerComponent(appName, () => App);
222+
```
223+
224+
Also wrap your entry point with `<GestureHandlerRootView>` or `gestureHandlerRootHO`
225+
226+
```jsx
227+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
228+
import { OverlayProvider } from 'stream-chat-react-native';
229+
230+
export default function App() {
231+
return (
232+
<GestureHandlerRootView>
233+
<OverlayProvider>{/* Your app code goes here */}</OverlayProvider>
234+
</GestureHandlerRootView>
235+
);
236+
}
237+
```
238+
239+
### Add Optional Dependencies
240+
241+
- `expo-av` - [additional installation steps](https://docs.expo.dev/versions/v45.0.0/sdk/video/)
242+
243+
> Available in stream-chat-expo >= v4.7.0
244+
245+
Installing this package allows you to play the video files/attachments in the chat. Otherwise by default, video files will be opened in default
246+
browser of the device.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Array of `video` file attachments.
2+
3+
```tsx
4+
const videos = message.attachments.filter(a => a.type === 'video' && !a.og_scrape_url);
5+
```
6+
7+
| Type |
8+
| ----- |
9+
| array |

docusaurus/docs/reactnative/common-content/core-components/channel/props/on_press_message.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@ For example:
2222

2323
```tsx
2424
<Channel
25-
onPressMessage={({ additionalInfo, defaultHandler, emitter }) => {
26-
if (emitter === 'textMention') {
27-
console.log(additionalInfo?.user);
28-
return;
29-
}
30-
defaultHandler?.();
31-
}}
25+
onPressMessage={({ additionalInfo, defaultHandler, emitter }) => {
26+
27+
if (emitter === 'textMention') {
28+
console.log(additionalInfo?.user);
29+
return;
30+
}
31+
32+
if (emitter === 'card' || emitter === 'textLink') {
33+
console.log(additionalInfo?.url);
34+
return;
35+
}
36+
37+
defaultHandler?.();
38+
}}
3239
>
3340
```
3441

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Component to render the video thumbnail for video attachments in MessageList.
2+
3+
| Type | Default |
4+
| --------- | ----------------------------------------------------------------- |
5+
| component | [`VideoThumbnail`](../../../../ui-components/video_thumbnail.mdx) |

docusaurus/docs/reactnative/contexts/message_context.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import GroupStyles from '../common-content/contexts/message-context/group_styles
1111
import HandleAction from '../common-content/contexts/message-context/handle_action.mdx';
1212
import HasReactions from '../common-content/contexts/message-context/has_reactions.mdx';
1313
import Images from '../common-content/contexts/message-context/images.mdx';
14+
import Videos from '../common-content/contexts/message-context/videos.mdx';
1415
import IsMyMessage from '../common-content/contexts/message-context/is_my_message.mdx';
1516
import LastGroupMessage from '../common-content/contexts/message-context/last_group_message.mdx';
1617
import MessageContentOrder from '../common-content/contexts/message-context/message_content_order.mdx';
@@ -223,6 +224,10 @@ Most recent message id in the message list.
223224

224225
<ThreadList />
225226

227+
### videos
228+
229+
<Videos />
230+
226231
<!-- ### goToMessage -->
227232

228233
<!-- ### preventPress -->

docusaurus/docs/reactnative/contexts/messages_context.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import SupportedReactions from '../common-content/core-components/channel/props/
6666
import TypingIndicator from '../common-content/core-components/channel/props/typing_indicator.mdx';
6767
import TypingIndicatorContainer from '../common-content/core-components/channel/props/typing_indicator_container.mdx';
6868
import UrlPreview from '../common-content/core-components/channel/props/url_preview.mdx';
69+
import VideoThumbnail from '../common-content/core-components/channel/props/video_thumbnail.mdx';
6970

7071
## Value
7172

@@ -384,3 +385,7 @@ Upserts a given message in local channel state. Please note that this function d
384385
### <div class="label description">_forwarded from [Channel](../core-components/channel.mdx#urlpreview)_ props</div> UrlPreview {#urlpreview}
385386

386387
<UrlPreview />
388+
389+
### <div class="label description">_forwarded from [Channel](../core-components/channel.mdx#videothumbnail)_ props</div> VideoThumbnail {#videoThumbnail}
390+
391+
<VideoThumbnail />

docusaurus/docs/reactnative/ui-components/gallery.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ import OnPressIn from '../common-content/contexts/message-context/on_press_in.md
2020
import OnlyEmojis from '../common-content/contexts/message-context/only_emojis.mdx';
2121
import OtherAttachments from '../common-content/contexts/message-context/other_attachments.mdx';
2222
import ThreadList from '../common-content/contexts/message-context/thread_list.mdx';
23+
import Videos from '../common-content/contexts/message-context/videos.mdx';
2324

2425
import SetOverlay from '../common-content/contexts/overlay-context/set_overlay.mdx';
2526

2627
import AdditionalTouchableProps from '../common-content/core-components/channel/props/additional_touchable_props.mdx';
2728
import LegacyImageViewerSwipeBehaviour from '../common-content/core-components/channel/props/legacy_image_viewer_swipe_behaviour.mdx';
29+
import VideoThumbnail from '../common-content/core-components/channel/props/video_thumbnail.mdx';
2830

2931
Component to render image attachments within the [`MessageList`](./message_list.mdx).
3032

@@ -119,3 +121,11 @@ If true, onPress handler will be disabled.
119121
### <div class="label description">_overrides the value from [MessageContext](../contexts/message_context.mdx#threadlist)_</div> threadList {#threadlist}
120122

121123
<ThreadList />
124+
125+
### <div class="label description">_overrides the value from [MessageContext](../contexts/message_context.mdx#videos)_</div> videos {#videos}
126+
127+
<Videos />
128+
129+
### <div class="label description">_overrides the value from [MessageContext](../contexts/messages_context.mdx#videothumbnail)_</div> VideoThumbnail {#videoThumbnail}
130+
131+
<VideoThumbnail />
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: video-thumbnail
3+
title: Video Thumbnail
4+
---
5+
6+
`VideoThumbnail` is a default UI component for rendering video thumbnail for video attachments within `MessageList`. This component doesn't accept any props.

0 commit comments

Comments
 (0)