-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2690 from GetStream/develop
Next Release
- Loading branch information
Showing
74 changed files
with
2,110 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v20 | ||
v20 |
5 changes: 5 additions & 0 deletions
5
...us/docs/reactnative/common-content/contexts/thread-list-item-context/thread.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
An instance of the [`Thread` class](https://github.com/GetStream/stream-chat-js/blob/master/src/thread.ts) that can be used to either get more data about the thread or pass to `onThreadSelect`. | ||
|
||
| Type | | ||
| ------ | | ||
| Thread | |
5 changes: 5 additions & 0 deletions
5
...actnative/common-content/contexts/threads-context/additional-flatlist-props.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
An object containing [`FlatListProps`](https://reactnative.dev/docs/flatlist#props) that can be used to override the default ones provided in the `ThreadList`. | ||
|
||
| Type | | ||
| ------ | | ||
| object | |
18 changes: 18 additions & 0 deletions
18
docusaurus/docs/reactnative/common-content/contexts/threads-context/is-focused.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
A boolean indicating if the `ThreadList` is currently in focus or not. Essentially a flag that lets us know whether the component is present in the viewport. Whenever present, it controls when updates to the `ThreadList` are active and when they are not. Best used in conjunction with hooks from popular navigation libraries (such as [`useIsFocused()` from React Navigation](https://reactnavigation.org/docs/use-is-focused/)) for lazy loading purposes. | ||
|
||
| Type | | ||
| ------- | | ||
| boolean | | ||
|
||
Example: | ||
|
||
```tsx | ||
import React from 'react'; | ||
import { useIsFocused } from '@react-navigation/native'; | ||
import { ThreadList } from 'stream-chat-react-native'; | ||
|
||
export const ThreadListScreen = () => { | ||
const isFocused = useIsFocused(); | ||
return <ThreadList isFocused={isFocused} />; | ||
}; | ||
``` |
19 changes: 19 additions & 0 deletions
19
...s/docs/reactnative/common-content/contexts/threads-context/on-thread-select.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
A method that will be used as a callback whenever a thread in the list is clicked. As an example, it can be used to navigate to a thread screen displaying the thread. | ||
|
||
| Type | | ||
| ------------------------------------ | | ||
| `(thread, channel) => Promise<void>` | | ||
|
||
The arguments passed are as follows: | ||
|
||
#### `thread` | ||
|
||
An object containing two properties, `thread` and `threadInstance`. This entire object can be passed as the [`thread` prop](../core-components/channel#thread) to the `Channel` component. | ||
|
||
| Type | | ||
| ------ | | ||
| object | | ||
|
||
The `threadInstance` property is an instance of the [`Thread` class](https://github.com/GetStream/stream-chat-js/blob/master/src/thread.ts). | ||
|
||
The `thread` property is a reference to the parent message of the thread. |
5 changes: 5 additions & 0 deletions
5
...ative/common-content/contexts/threads-context/thread-list-empty-placeholder.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
A custom UI component used to render the empty placeholder if there are no available threads. | ||
|
||
| Type | Default | | ||
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| ComponentType | [`DefaultThreadListEmptyPlaceholder`](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ThreadList/ThreadList.tsx) | |
39 changes: 39 additions & 0 deletions
39
...s/docs/reactnative/common-content/contexts/threads-context/thread-list-item.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
A custom UI component used to render each item within the `ThreadList`. It will override the UI of the [default `ThreadListItem`](./thread-list-item) while still keeping all of the data. | ||
|
||
| Type | Default | | ||
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | ||
| ComponentType | [`ThreadListItem`](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ThreadList/ThreadListItem.tsx) | | ||
|
||
Example usage: | ||
|
||
```tsx | ||
import { Text, TouchableOpacity } from 'react-native'; | ||
import { | ||
OverlayProvider, | ||
Chat, | ||
ThreadList, | ||
useThreadListItemContext, | ||
useThreadsContext, | ||
} from 'stream-chat-react-native'; | ||
|
||
const ThreadListItem = () => { | ||
const { parentMessage, thread, channel } = useThreadListItemContext(); | ||
const { onThreadSelect } = useThreadsContext(); | ||
|
||
return ( | ||
<TouchableOpacity onPress={() => onThreadSelect(thread, channel)}> | ||
<Text>{parentMessage?.text || 'Text not available !'}</Text> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
const App = () => { | ||
return ( | ||
<OverlayProvider> | ||
<Chat client={client}> | ||
<ThreadList ThreadListItem={ThreadListItem} /> | ||
</Chat> | ||
</OverlayProvider> | ||
); | ||
}; | ||
``` |
5 changes: 5 additions & 0 deletions
5
...ative/common-content/contexts/threads-context/thread-list-loading-indicator.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
A custom UI component used to render the loading indicator when `isLoading` is `true`. | ||
|
||
| Type | Default | | ||
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| ComponentType | [`DefaultThreadListLoadingIndicator`](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ThreadList/ThreadList.tsx) | |
5 changes: 5 additions & 0 deletions
5
.../common-content/contexts/threads-context/thread-list-loading-more-indicator.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
A custom UI component used to render the loading indicator when `isLoadingNext` is `true`. | ||
|
||
| Type | Default | | ||
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| ComponentType | [`DefaultThreadListLoadingMoreIndicator`](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ThreadList/ThreadList.tsx) | |
5 changes: 5 additions & 0 deletions
5
...actnative/common-content/contexts/threads-context/thread-list-unread-banner.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
A custom UI component used to render the unread threads banner at the top of the list. | ||
|
||
| Type | Default | | ||
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| ComponentType | [`ThreadListUnreadBanner`](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ThreadList/ThreadListUnreadBanner.tsx) | |
73 changes: 73 additions & 0 deletions
73
docusaurus/docs/reactnative/contexts/thread-list-item-context.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
id: thread-list-item-context | ||
title: ThreadListItemContext | ||
--- | ||
|
||
import Channel from '../common-content/ui-components/channel/props/channel.mdx'; | ||
|
||
import Thread from '../common-content/contexts/thread-list-item-context/thread.mdx'; | ||
|
||
The `ThreadListItemContext` is provided by the [`ThreadListItem`](../../ui-components/thread-list-item) component. If you are not familiar with React Context API, please read about it on [React docs](https://reactjs.org/docs/context.html). | ||
|
||
The `ThreadListItemContext` needs to be used within the [`ThreadList` component](../../ui-components/thread-list) as it depends on the [`ThreadsContext`](../threads-context). | ||
|
||
## Basic Usage | ||
|
||
The `ThreadListItemContext` can be consumed by any of the child components of `ThreadList` component as following: | ||
|
||
```tsx | ||
import { useContext } from 'react'; | ||
import { ThreadListItemContext } from 'stream-chat-react-native'; | ||
|
||
const value = useContext(ThreadListItemContext); | ||
``` | ||
|
||
Alternatively, you can also use `useThreadListItemContext` hook provided by library to consume `ThreadListItemContext`. | ||
|
||
```tsx | ||
import { useThreadListItemContext } from 'stream-chat-react-native'; | ||
|
||
const value = useThreadListItemContext(); | ||
``` | ||
|
||
## Value | ||
|
||
### `channel` | ||
|
||
<Channel /> | ||
|
||
### `dateString` | ||
|
||
A formatted date string that can be used as a thread timestamp. The default format is `HH:MM`. | ||
|
||
| Type | | ||
| ------ | | ||
| string | | ||
|
||
### `lastReply` | ||
|
||
A [Message instance](https://github.com/GetStream/stream-chat-react-native/blob/493cdffcb5b2ee915b2f420e359ad685966a0dbe/package/src/components/MessageList/hooks/useMessageList.ts#L35) providing the latest message reply in the thread. | ||
|
||
| Type | | ||
| ----------- | | ||
| MessageType | | ||
|
||
### `ownUnreadMessageCount` | ||
|
||
A number providing the number of unread messages for the particular thread. | ||
|
||
| Type | | ||
| ------ | | ||
| number | | ||
|
||
### `parentMessage` | ||
|
||
A [Message instance](https://github.com/GetStream/stream-chat-react-native/blob/493cdffcb5b2ee915b2f420e359ad685966a0dbe/package/src/components/MessageList/hooks/useMessageList.ts#L35) providing the parent message of the thread. | ||
|
||
| Type | | ||
| ----------- | | ||
| MessageType | | ||
|
||
### `thread` | ||
|
||
<Thread /> |
108 changes: 108 additions & 0 deletions
108
docusaurus/docs/reactnative/contexts/threads-context.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
--- | ||
id: threads-context | ||
title: ThreadsContext | ||
--- | ||
|
||
import Channel from '../common-content/ui-components/channel/props/channel.mdx'; | ||
|
||
import AdditionalFlatListProps from '../common-content/contexts/threads-context/additional-flatlist-props.mdx'; | ||
import IsFocused from '../common-content/contexts/threads-context/is-focused.mdx'; | ||
import OnThreadSelect from '../common-content/contexts/threads-context/on-thread-select.mdx'; | ||
import ThreadListItem from '../common-content/contexts/threads-context/thread-list-item.mdx'; | ||
import ThreadListEmptyPlaceholder from '../common-content/contexts/threads-context/thread-list-empty-placeholder.mdx'; | ||
import ThreadListLoadingIndicator from '../common-content/contexts/threads-context/thread-list-loading-indicator.mdx'; | ||
import ThreadListLoadingMoreIndicator from '../common-content/contexts/threads-context/thread-list-loading-more-indicator.mdx'; | ||
import ThreadListUnreadBanner from '../common-content/contexts/threads-context/thread-list-unread-banner.mdx'; | ||
|
||
The `ThreadsContext` is provided by the [`ThreadList`](../../ui-components/thread-list) component. If you are not familiar with React Context API, please read about it on [React docs](https://reactjs.org/docs/context.html). | ||
|
||
The `ThreadsContext` needs to be used within the [`Chat` component](../../core-components/chat) as it depends on the [`ChatContext`](./chat-context). | ||
|
||
## Basic Usage | ||
|
||
The `ThreadsContext` can be consumed by any of the child components of `Chat` as following: | ||
|
||
```tsx | ||
import { useContext } from 'react'; | ||
import { ThreadsContext } from 'stream-chat-react-native'; | ||
|
||
const value = useContext(ThreadsContext); | ||
``` | ||
|
||
Alternatively, you can also use `useThreadsContext` hook provided by library to consume `ThreadContext`. | ||
|
||
```tsx | ||
import { useThreadsContext } from 'stream-chat-react-native'; | ||
|
||
const value = useThreadsContext(); | ||
``` | ||
|
||
## Value | ||
|
||
### `isLoading` \* | ||
|
||
A boolean flag that lets us know whether the threads are currently loading or not. | ||
|
||
| Type | Default | | ||
| ------- | ------- | | ||
| boolean | false | | ||
|
||
### `isLoadingMore` \* | ||
|
||
A boolean flag that lets us whether the next page of threads is being loaded or not. | ||
|
||
| Type | Default | | ||
| ------- | ------- | | ||
| boolean | false | | ||
|
||
### `threads` \* | ||
|
||
An array of [Thread](https://github.com/GetStream/stream-chat-js/blob/master/src/thread.ts) instances that are used as input for rendering the `ThreadList`. | ||
|
||
| Type | | ||
| ----- | | ||
| array | | ||
|
||
### `isFocused` | ||
|
||
<IsFocused /> | ||
|
||
### `additionalFlatListProps` | ||
|
||
<AdditionalFlatListProps /> | ||
|
||
### `loadMore` | ||
|
||
A method that can be invoked to load more `threads`. Returns a promise. | ||
|
||
| Type | | ||
| --------------------- | | ||
| `() => Promise<void>` | | ||
|
||
### `onThreadSelect` | ||
|
||
<OnThreadSelect /> | ||
|
||
#### `channel` | ||
|
||
<Channel /> | ||
|
||
### `ThreadListEmptyPlaceholder` | ||
|
||
<ThreadListEmptyPlaceholder /> | ||
|
||
### `ThreadListItem` | ||
|
||
<ThreadListItem /> | ||
|
||
### `ThreadListLoadingIndicator` | ||
|
||
<ThreadListLoadingIndicator /> | ||
|
||
### `ThreadListLoadingMoreIndicator` | ||
|
||
<ThreadListLoadingMoreIndicator /> | ||
|
||
### `ThreadListUnreadBanner` | ||
|
||
<ThreadListUnreadBanner /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.