Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: resolve conflicts from develop #2682

Merged
merged 42 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f5822dd
fix: upgrade firebase versions to fix crash (#2646)
isekovanic Aug 30, 2024
2011eb2
fix: audio recording variety bugs (#2648)
isekovanic Sep 3, 2024
c0f7cf2
docs: add Deep Linking guide for the chat SDK (#2651)
khushal87 Sep 4, 2024
327aeac
fix: change Block user action to Ban user action and UI cookbook for …
khushal87 Sep 4, 2024
b5d59a8
Merge pull request #2652 from GetStream/develop
khushal87 Sep 4, 2024
bbc63f1
chore(release): 5.36.1 [skip ci]
semantic-release-bot Sep 4, 2024
2d596ed
chore(release): 1.28.1 [skip ci]
semantic-release-bot Sep 4, 2024
9421a33
fix: issue with loading app settings when the connectUser is not call…
khushal87 Sep 5, 2024
c2dacb2
fix: unable to upload file due to special characters in the file name…
khushal87 Sep 6, 2024
233faa1
fix: sdk size pr (#2657)
testableapple Sep 6, 2024
3a1b3c2
[CI] Update SDK Size (#2653)
Stream-SDK-Bot Sep 6, 2024
5ee8382
Merge pull request #2658 from GetStream/develop
khushal87 Sep 9, 2024
9c93ed2
chore(release): 5.36.2 [skip ci]
semantic-release-bot Sep 9, 2024
1828ce6
chore(release): 1.28.2 [skip ci]
semantic-release-bot Sep 9, 2024
8ee1375
feat: add live location sharing cookbook (#2659)
santhoshvai Sep 10, 2024
5fda8c3
Merge pull request #2662 from GetStream/develop
santhoshvai Sep 10, 2024
4ec8f2b
chore(release): 5.37.0 [skip ci]
semantic-release-bot Sep 10, 2024
a3b80b2
chore(release): 1.29.0 [skip ci]
semantic-release-bot Sep 10, 2024
9f873ca
fix: avoid prepending http before native supported url schemes (#2661)
isekovanic Sep 10, 2024
de2724a
fix: bad memoisation in window, screen dimension listener hooks (#2664)
santhoshvai Sep 10, 2024
68cc67a
feat: add create chat client hook for easy usage (#2660)
khushal87 Sep 10, 2024
aea64f1
fix: bump fastlane plugin version (#2665)
testableapple Sep 11, 2024
2944c07
fix: add theme properties for EmptyStateIndicator for message list (#…
khushal87 Sep 12, 2024
c5951bc
fix: apply card cover theme property order
khushal87 Sep 12, 2024
493cdff
fix: pagination typescript errors and db synchronization bugs (#2669)
isekovanic Sep 13, 2024
98a2f6c
[CI] Bump max tolerance for sdk size analysis (#2674)
testableapple Sep 17, 2024
9179398
chore: bump sample app version to v1.30.0
isekovanic Sep 17, 2024
3497bcb
fix: remove nin and ne operator usage in the SDK and the sample app…
khushal87 Sep 18, 2024
680b6c8
fix: request image access permissions for iOS only for native image p…
khushal87 Sep 18, 2024
87d85c6
fix: properly resolve sendMessage during memoization (#2675)
isekovanic Sep 18, 2024
b9b5cd7
fix: deprecate messageReactions prop and use isMessageActionsVisible …
khushal87 Sep 18, 2024
c3c0552
Merge pull request #2673 from GetStream/develop
khushal87 Sep 18, 2024
f890264
chore(release): 5.38.0 [skip ci]
semantic-release-bot Sep 18, 2024
684b298
chore(release): 1.29.1 [skip ci]
semantic-release-bot Sep 18, 2024
84d678c
fix: update yarn.lock for the project (#2681)
khushal87 Sep 19, 2024
6398b73
fix: copy message action type for message actions (#2679)
khushal87 Sep 19, 2024
5cd6cd4
chore: update sdk size (#2678)
Stream-SDK-Bot Sep 19, 2024
057a77f
chore: resolve conflicts from develop
khushal87 Sep 19, 2024
3c7a3ce
fix: vale lint issues
khushal87 Sep 19, 2024
346262a
Merge branch 'develop' of github.com:GetStream/stream-chat-react-nati…
khushal87 Sep 19, 2024
cdb08d9
fix: vale lint issues
khushal87 Sep 19, 2024
6c04db1
fix: new arch project config
khushal87 Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![NPM](https://img.shields.io/npm/v/stream-chat-react-native.svg)](https://www.npmjs.com/package/stream-chat-react-native)
[![Build Status](https://github.com/GetStream/stream-chat-react-native/actions/workflows/release.yml/badge.svg)](https://github.com/GetStream/stream-chat-react-native/actions)
[![Component Reference](https://img.shields.io/badge/docs-component%20reference-blue.svg)](https://getstream.io/chat/docs/sdk/reactnative)
![JS Bundle Size](https://img.shields.io/badge/js_bundle_size-439%20KB-blue)
![JS Bundle Size](https://img.shields.io/badge/js_bundle_size-442%20KB-blue)

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

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Function called when the _Ban User_ action is invoked from message actions list.
This function does not override the default behavior of the _Ban User_ action.
Please refer to [the guide on customizing message actions](../../../../guides/custom-message-actions.mdx) for details.

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

| Parameter | Description |
| --------- | ------------------------------- |
| message | message the action is called on |
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
:::note
This is deprecated. Please use `handleBan` instead.
:::

Function called when the _Block User_ action is invoked from message actions list.
This function does not override the default behavior of the _Block User_ action.
Please refer to [the guide on customizing message actions](../../../../guides/custom-message-actions.mdx) for details.

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

| Type |
| --------- | ------------------------------- |
| function |
| Parameter | Description |
| --------- | ------------------------------- |
| message | message the action is called on |
5 changes: 5 additions & 0 deletions docusaurus/docs/reactnative/contexts/messages-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import FormatDate from '../common-content/ui-components/channel/props/format_dat
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';
Expand Down Expand Up @@ -110,6 +111,10 @@ Id of current channel.

<FormatDate />

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

<HandleBan />

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

<HandleBlock />
Expand Down
5 changes: 5 additions & 0 deletions docusaurus/docs/reactnative/core-components/channel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import Giphy from '../common-content/ui-components/channel/props/giphy.mdx';
import GiphyEnabled from '../common-content/ui-components/channel/props/giphy_enabled.mdx';
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';
Expand Down Expand Up @@ -486,6 +487,10 @@ The max allowable is 255, which when reached displays as `255+`.

<HandleAttachButtonPress />

### `handleBan`

<HandleBan />

### `handleBlock`

<HandleBlock />
Expand Down
48 changes: 36 additions & 12 deletions docusaurus/docs/reactnative/core-components/chat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,45 @@ We recommend using only one instance of `Chat` provider per application unless a

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

const client = StreamChat.getInstance('api_key');

export const App = () => (
<OverlayProvider>
// highlight-next-line
<Chat client={client}>
<ChannelList />
import { ChannelList, Chat, OverlayProvider, useCreateChatClient } from 'stream-chat-react-native';

// highlight-start
const chatApiKey = 'REPLACE_WITH_API_KEY';
const chatUserId = 'REPLACE_WITH_USER_ID';
const chatUserName = 'REPLACE_WITH_USER_NAME';
const chatUserToken = 'REPLACE_WITH_USER_TOKEN';
// highlight-end

const user = {
id: chatUserId,
name: chatUserName,
};

export const App = () => {
// highlight-start
const chatClient = useCreateChatClient({
apiKey: chatApiKey,
userData: user,
tokenOrProvider: chatUserToken,
});
// highlight-end

return (
<OverlayProvider>
// highlight-next-line
</Chat>
</OverlayProvider>
);
<Chat client={chatClient}>
<ChannelList />
// highlight-next-line
</Chat>
</OverlayProvider>
);
};
```

:::tip
You can use the `useCreateChatClient` hook from `stream-chat-react-native`/`stream-chat-expo` to create a client instance and automatically connect/disconnect a user as per the example above, for simplicity.
:::

## Context Providers

`Chat` contains providers for the `ChatContext`, `ThemeContext`, and `TranslationContext`.
Expand Down
201 changes: 201 additions & 0 deletions docusaurus/docs/reactnative/guides/blocking-users.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
---
id: blocking-users
title: Blocking Users
---

## Introduction

Blocking users is an essential feature in a chat app because it enhances user safety and experience. It allows individuals to protect themselves from harassment, spam, and unwanted interactions. By giving users control over their interactions, it helps maintain privacy, reduces the risk of cyber-bullying, and promotes a respectful community atmosphere.

As a result, some app stores require this functionality as part of their review process.

## Stream Chat

The Stream Chat SDK provides a way for blocking and unblocking users, as well as listing all of the blocked users.

When you block a user, you won’t receive any direct messages from that user anymore. However, if you share a group with other participants, you will still receive messages from the blocked user.

In this cookbook, we will see how to implement this feature in your chat apps, using the Stream Chat SDK.

## Low Level Client support

The low-level client provides the following methods related to user blocking.

### Blocking a user

In order to block a user, you need to use the `blockUser` method of the client instance. This method takes the user id of the user you wish to block.

```tsx
import { StreamChat } from 'stream-chat';
const chatClient = StreamChat.getInstance('your api key');

// Note this has to be done after the client connection(`client.connectUser`) is established.
const blockUser = async (userId: string) => {
try {
await chatClient.blockUser(userId);
} catch (err) {
console.log('Error blocking user:', err);
}
};
```

### Unblocking a user

Similarly, to unblock a blocked user, you need to use the `unBlockUser` method of the client instance. This method takes the user id of the user you wish to unblock.

```tsx
import { StreamChat } from 'stream-chat';
const chatClient = StreamChat.getInstance('your api key');

// Note this has to be done after the client connection(`client.connectUser`) is established.
const unBlockUser = async (userId: string) => {
try {
await chatClient.unBlockUser(userId);
} catch (err) {
console.log('Error UnBlocking user:', err);
}
};
```

### Listing Blocked Users

To list all the blocked users, you can use the `getBlockedUsers` method of the client instance.

```tsx
const chatClient = StreamChat.getInstance('your api key');

// Note this has to be done after the client connection(`client.connectUser`) is established.
const getBlockedUsers = async () => {
try {
const users = await chatClient.getBlockedUsers();
setBlockedUsers(users.blocks);
} catch (error) {
console.log('Error getting blocked users:', error);
}
};
```

## Message Actions

You can use the logic above to create your own custom message actions that will involve user blocking.

This can be done by using the `messageActions` prop of the `Channel` component. You can follow the guide [here](../guides/custom-message-actions.mdx).

```tsx
import { Channel, messageActions } from 'stream-chat-react-native';

const App = () => {
return (
<Channel
channel={channel}
messageActions={params => {
const { dismissOverlay, message } = params;
const actions = messageActions({ ...params });
if (actions) {
actions.push({
action: async () => {
try {
await chatClient.blockUser(message.user?.id || '');
dismissOverlay();
} catch (error) {
console.log('Error blocking user:', error);
}
},
actionType: 'block-user',
title: 'Block User',
});
return actions;
} else {
return [];
}
}}
>
{/* Other components here */}
</Channel>
);
};
```

## Displaying Blocked users

Next, let’s see how we can build a custom UI that will show the list of blocked users. This will allow easier overview for the users about who they blocked, as well as provide an easy way to unblock them if needed.

![Blocked Users](../assets/guides/blocking-users/blocked-users-list.png)

```tsx
import { useEffect, useState } from 'react';
import { Image, StyleSheet, Text, View } from 'react-native';
import { BlockedUserDetails, StreamChat } from 'stream-chat';

const chatClient = StreamChat.getInstance('your api key');

const BlockedUsers = () => {
const [blockedUsers, setBlockedUsers] = useState<BlockedUserDetails[]>([]);

useEffect(() => {
const getBlockedUsers = async () => {
try {
const users = await chatClient.getBlockedUsers();
setBlockedUsers(users.blocks);
} catch (error) {
console.log('Error getting blocked users:', error);
}
};

getBlockedUsers();
}, []);

const unBlockUser = async (userId: string) => {
try {
await chatClient.unBlockUser(userId);
const filteredUsers = blockedUsers.filter(user => user.blocked_user_id !== userId);
setBlockedUsers(filteredUsers);
} catch (err) {
console.log('Error UnBlocking user:', err);
}
};

return (
<View>
{blockedUsers.map((blockedUser: BlockedUserDetails) => (
<Pressable
key={blockedUser.blocked_user_id}
onPress={() => {
unBlockUser(blockedUser.blocked_user_id);
}}
style={styles.container}
>
<Image source={{ uri: blockedUser.blocked_user.image as string }} style={styles.image} />
<Text style={styles.name}>{blockedUser.blocked_user.name}</Text>
</Pressable>
))}
</View>
);
};

const styles = StyleSheet.create({
container: {
flexDirection: 'row',
padding: 16,
alignItems: 'center',
},
image: {
height: 80,
width: 80,
borderRadius: 40,
},
name: {
fontSize: 16,
fontWeight: 'bold',
marginLeft: 16,
},
});
```

There’s nothing special in this view, it just shows the blocked users in a list, and exposes a delete action, which will remove the blocked user from the list.

## Summary

In this cookbook we have seen the capabilities of the Stream Chat SDK for blocking users. We have also seen how to add message actions to block and unblock users, as well as a custom UI for displaying the blocked users.

It is recommended to use these actions, in order to avoid issues during app store reviews, especially on the Apple platforms.
5 changes: 3 additions & 2 deletions docusaurus/docs/reactnative/guides/custom-message-actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ messageActions={({
editMessage, // MessageAction | null;
error, // boolean;
flagMessage, // MessageAction | null;
isMessageActionsVisible, // boolean;
isMyMessage, // boolean;
isThreadMessage, // boolean;
message, // MessageType<At, Ch, Co, Ev, Me, Re, Us>;
messageReactions, // boolean;
reply, // MessageAction | null;
retry, // MessageAction | null;
threadReply, // MessageAction | null;
Expand Down Expand Up @@ -390,7 +390,8 @@ These functions will be called right before the underlying default handlers.
Please note that these intercepts will neither change the standard functions nor block them.
:::

- `handleBlock`
- `handleBan`
- `handleBlock`(deprecated)
- `handleCopy`
- `handleDelete`
- `handleEdit`
Expand Down
Loading
Loading