Skip to content

Commit

Permalink
chore: resolve conflicts from base branc
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Oct 11, 2024
2 parents 935a453 + 0e5a3ef commit 1019598
Show file tree
Hide file tree
Showing 59 changed files with 203 additions and 961 deletions.
37 changes: 37 additions & 0 deletions docusaurus/docs/reactnative/basics/migrating-from-5.x-to-6.x.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,36 @@ We have introduced a new ReactionList design that is more intuitive and provides

You can switch to `bottom` reaction list design by setting the [`reactionListPosition`](../core-components/channel.mdx#reactionlistposition) prop to `bottom` in the `Channel` component. The Reaction list component can be completely customized by providing a custom component to the [`ReactionListTop`](../core-components/channel.mdx#reactionlisttop) prop in the `Channel` component for top reactions list and [`ReactionListBottom`](../core-components/channel.mdx#reactionlistbottom) prop for bottom reactions list. The default mode is `top` as it was in the previous version.

#### Remove `StreamChatRN` and introduce `ChatConfigContext`

The `StreamChatRN` global config is removed in favour of the `ChatConfigContext`. The `ChatConfigContext` is a more versatile and feature-rich context that can be used to provide any global configuration to the chat application.

The `resizableCDNHosts` can be configured by wrapping the root of your Chat application with `ChatConfigProvider` as follows:

```tsx
import { Chat, ChatConfigProvider, OverlayProvider } from 'stream-chat-react-native';

const App = () => {
return (
<ChatConfigProvider
value={{
resizableCDNHosts: ['cdn.example.com'],
}}
>
<OverlayProvider>
<Chat client={client}>
<ChannelList />
</Chat>
</OverlayProvider>
</ChatConfigProvider>
);
};
```

:::note
If nothing is provided, the `resizableCDNHosts` will default to `['.stream-io-cdn.com']`.
:::

#### Removed `MessageOverlayContext` and `MessageOverlayProvider`

The `MessageOverlayContext` and `MessageOverlayProvider` have been removed.
Expand Down Expand Up @@ -185,6 +215,13 @@ The type of `quotedMessage` is changed from `MessageType | boolean` to `Message

The default theme object has been refactored to provide a better customization experience. The theme object is now more organized and provides better control over the customization. You can check the object [here](https://github.com/GetStream/stream-chat-react-native/blob/develop/package/src/contexts/themeContext/utils/theme.ts).

#### Remove the deprecated code

- We have removed `loadChannelAtMessage` from channel context because it was no more used.
- We have removed the `handleDeleteMessage`, `handleEditMessage`, `handleQuotedReplyMessage`, `handleResendMessage`, `handleToggleBanUser` and `handleToggleMuteUser` from the message context because it was no more used. To customize the message actions follow the [customization documentation](../guides/custom-message-actions.mdx).
- Remove the `onMessageNew` prop from the [`ChannelList`](../core-components/channel-list.mdx) component. Use the [`onNewMessage`](../core-components/channel-list.mdx#onnewmessage) prop instead.
- Remove the `handleBlock` prop from the `Channel` component. Use [`handleBan`](../core-components/channel.mdx#handleban) instead.

## Other changes

- The `useMessageActions` hook doesn't take `setOverlay` anymore but takes in `dismissOverlay`.
Expand Down
22 changes: 0 additions & 22 deletions docusaurus/docs/reactnative/contexts/channel-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,6 @@ loadChannelAroundMessage({
| -------- |
| function |

### loadChannelAtMessage

Function to reload channel at particular message in history.

:::caution

This function is deprecated. Use [loadChannelAroundMessage](#loadchannelaroundmessage) instead.

:::

```tsx
loadChannelAtMessage({
before: 10, // Number of messages to load before messageId
after: 10, // Number of messages to load after messageId
messageId,
});
```

| Type |
| -------- |
| function |

### loading

True if channel is loading messages during first load.
Expand Down
8 changes: 0 additions & 8 deletions docusaurus/docs/reactnative/contexts/chat-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,5 @@ Array of users muted by current user.
| ----- |
| array |

### `resizableCDNHosts`

This option allows you to specify a list of CDNs that offer image resizing.

| Type | Default |
| ---------- | ------------------------ |
| `string[]` | `['.stream-io-cdn.com']` |

<!-- ### setActiveChannel -->
<!-- ### channel -->
48 changes: 0 additions & 48 deletions docusaurus/docs/reactnative/contexts/message-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,54 +90,6 @@ True if one of the following condition is true:

<HandleAction />

### handleDeleteMessage

Callback function for "Delete Message" action.

| Type |
| -------- |
| function |

### handleEditMessage

Callback function for "Edit Message" action.

| Type |
| -------- |
| function |

### handleQuotedReplyMessage

Callback function for "Quoted Reply" action.

| Type |
| -------- |
| function |

### handleResendMessage

Callback function for "Resend Message" (for failed message) action.

| Type |
| -------- |
| function |

### handleToggleBanUser

Callback function for "Ban/Unban User" action.

| Type |
| -------- |
| function |

### handleToggleMuteUser

Callback function for "Mute/Unmute User" action.

| Type |
| -------- |
| function |

### handleToggleReaction

Callback function for toggling reaction from reaction selector.
Expand Down
5 changes: 0 additions & 5 deletions docusaurus/docs/reactnative/contexts/messages-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import Gallery from '../common-content/ui-components/channel/props/gallery.mdx';
import Giphy from '../common-content/ui-components/channel/props/giphy.mdx';
import GiphyVersion from '../common-content/ui-components/channel/props/giphy_version.mdx';
import HandleBan from '../common-content/ui-components/channel/props/handle_ban.mdx';
import HandleBlock from '../common-content/ui-components/channel/props/handle_block.mdx';
import HandleCopy from '../common-content/ui-components/channel/props/handle_copy.mdx';
import HandleDelete from '../common-content/ui-components/channel/props/handle_delete.mdx';
import HandleEdit from '../common-content/ui-components/channel/props/handle_edit.mdx';
Expand Down Expand Up @@ -124,10 +123,6 @@ Id of current channel.

<HandleBan />

### <div class="label description">_forwarded from [Channel](../../core-components/channel#handleblock)_ props</div> `handleBlock` {#handleblock}

<HandleBlock />

### <div class="label description">_forwarded from [Channel](../../core-components/channel#handlecopy)_ props</div> `handleCopy` {#handlecopy}

<HandleCopy />
Expand Down
2 changes: 1 addition & 1 deletion docusaurus/docs/reactnative/contexts/overlay-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Detailed information on theming can be found in the [customization documentation
:::note

Themes are inherited from parent providers.
A [theme provided to the `OverlayProvider`](../core-components/overlay-provider.mdx) will be the base theme `style` is merged into.
A [theme provided to the `OverlayProvider`](../core-components/overlay-provider.mdx#value) will be the base theme `style` is merged into.
Themes are not hoisted though, therefore a theme provided to `Chat` will not change overlay components such as the attachment picker.

:::
Expand Down
15 changes: 0 additions & 15 deletions docusaurus/docs/reactnative/core-components/channel-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,6 @@ Override for the default Event Listener behavior when a channel is updated. Th
| setChannels | Setter function for the internal channels state |
| event | [Event Object](https://getstream.io/chat/docs/react/event_object/#event-object) corresponding to channel.deleted |

### `onMessageNew`

Override for the default Event Listener behavior when a message is received on a channel that is not being watched. The default behavior adds the channel to the list.

> Warning: This function is deprecated. Use **[`onNewMessageNotification`](#onNewMessageNotification)** instead.
| Type |
| -------- |
| Function |

| Parameter | Description |
| ----------- | ---------------------------------------------------------------------------------------------------------------- |
| setChannels | Setter function for the internal channels state |
| event | [Event Object](https://getstream.io/chat/docs/react/event_object/#event-object) corresponding to channel.deleted |

### **`onNewMessageNotification`**

Override for the default Event Listener behavior when a message is received on a channel that is not being watched. The default behavior adds the channel to the list.
Expand Down
5 changes: 0 additions & 5 deletions docusaurus/docs/reactnative/core-components/channel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import GiphyEnabled from '../common-content/ui-components/channel/props/giphy_en
import GiphyVersion from '../common-content/ui-components/channel/props/giphy_version.mdx';
import HandleAttachButtonPress from '../common-content/ui-components/channel/props/handle_attach_button_press.mdx';
import HandleBan from '../common-content/ui-components/channel/props/handle_ban.mdx';
import HandleBlock from '../common-content/ui-components/channel/props/handle_block.mdx';
import HandleCopy from '../common-content/ui-components/channel/props/handle_copy.mdx';
import HandleDelete from '../common-content/ui-components/channel/props/handle_delete.mdx';
import HandleEdit from '../common-content/ui-components/channel/props/handle_edit.mdx';
Expand Down Expand Up @@ -501,10 +500,6 @@ The max allowable is 255, which when reached displays as `255+`.

<HandleBan />

### `handleBlock`

<HandleBlock />

### `handleCopy`

<HandleCopy />
Expand Down
8 changes: 0 additions & 8 deletions docusaurus/docs/reactnative/core-components/chat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ Themes are not hoisted though, therefore a theme provided to `Chat` will not cha
| ------ |
| Object |

### `resizableCDNHosts`

This option allows you to specify a list of CDNs that offer image resizing.

| Type | Default |
| ---------- | ------------------------ |
| `string[]` | `['.stream-io-cdn.com']` |

## UI Component Props

### `ImageComponent`
Expand Down
43 changes: 26 additions & 17 deletions docusaurus/docs/reactnative/customization/global_config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,42 @@ title: Global Config
---

The core of Stream Chat for React Native is it's ability to be customized to your needs.
The new `Global Config` feature allows you to enable and disable features of the library and alter the default behavior of the SDK.

:::info
This will be not be the recommended way of setting the config in the next major version of the SDK that is v6.

Use the `resizableCDNHosts` prop in the [`Chat`](../core-components/chat.mdx) component instead.
:::
The new `Global Chat Config` feature allows you to enable and disable features of the library and alter the default behavior of the SDK.

## When to use global config

When you want to alter the default behavior of the SDK or it's components.
Please check the available options below to see if there is a config option that fits your needs.
When you want to alter the default behavior of the SDK such as changing the CDN hosts.

## How to use and alter the global config

Altering the global config can be done by calling the `setConfig` function on the `StreamChatRN` object.
Make sure to call this function before any other components are rendered at the root of your application (App.tsx in most cases).
The `ChatConfigProvider` is a context provider that can be used to provide global configuration to the chat application.

```tsx
import { StreamChatRN } from 'stream-chat-react-native';
The `resizableCDNHosts` can be configured by wrapping the root of your Chat application with `ChatConfigProvider` as follows:

StreamChatRN.setConfig({
resizableCDNHosts: ['https://my-company-cdn.com'],
// future config options
});
```tsx
import { Chat, ChatConfigProvider, OverlayProvider } from 'stream-chat-react-native';

const App = () => {
return (
<ChatConfigProvider
value={{
resizableCDNHosts: ['cdn.example.com'],
}}
>
<OverlayProvider>
<Chat client={client}>
<ChannelList />
</Chat>
</OverlayProvider>
</ChatConfigProvider>
);
};
```

:::note
If nothing is provided, the `resizableCDNHosts` will default to `['.stream-io-cdn.com']`.
:::

## Available config features/Options

### `resizableCDNHosts`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ Please note that these intercepts will neither change the standard functions nor
:::
- `handleBan`
- `handleBlock`(deprecated)
- `handleCopy`
- `handleDelete`
- `handleEdit`
Expand Down
1 change: 1 addition & 0 deletions docusaurus/shared
3 changes: 3 additions & 0 deletions package/src/components/Attachment/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getGalleryImageBorderRadius } from './utils/getGalleryImageBorderRadius
import { openUrlSafely } from './utils/openUrlSafely';

import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
import { useChatConfigContext } from '../../contexts/chatConfigContext/ChatConfigContext';
import {
ImageGalleryContextValue,
useImageGalleryContext,
Expand Down Expand Up @@ -104,6 +105,7 @@ const GalleryWithContext = <
VideoThumbnail,
} = props;

const { resizableCDNHosts } = useChatConfigContext();
const {
theme: {
messageSimple: {
Expand Down Expand Up @@ -139,6 +141,7 @@ const GalleryWithContext = <
() =>
buildGallery({
images: imagesAndVideos,
resizableCDNHosts,
sizeConfig,
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import type { GallerySizeAndThumbnailGrid, GallerySizeConfig } from './types';

import type { DefaultStreamChatGenerics } from '../../../../types/types';

import {
ChatConfigContextValue,
chatConfigContextDefaultvalue,
} from '../../../../contexts/chatConfigContext/ChatConfigContext';

/**
* Builds and returns a gallery of optimized images to be rendered on UI.
* This function take a object parameter with following properties:
Expand All @@ -30,28 +35,32 @@ export function buildGallery<
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
>({
images,
resizableCDNHosts = chatConfigContextDefaultvalue.resizableCDNHosts,
sizeConfig,
}: {
}: Pick<ChatConfigContextValue, 'resizableCDNHosts'> & {
images: Attachment<StreamChatGenerics>[];
sizeConfig: GallerySizeConfig;
}): GallerySizeAndThumbnailGrid {
if (images.length === 1) {
return buildGalleryOfSingleImage({
image: images[0],
resizableCDNHosts,
sizeConfig,
});
}

if (images.length === 2) {
return buildGalleryOfTwoImages({
images,
resizableCDNHosts,
sizeConfig,
});
}

if (images.length === 3) {
return buildGalleryOfThreeImages({
images,
resizableCDNHosts,
sizeConfig,
});
}
Expand All @@ -72,6 +81,7 @@ export function buildGallery<
],
images: images.slice(0, 4),
invertedDirections: true,
resizableCDNHosts,
sizeConfig,
});
}
Loading

0 comments on commit 1019598

Please sign in to comment.