Skip to content

Commit

Permalink
chore: resolve conflicts from develop (#2682)
Browse files Browse the repository at this point in the history
* fix: upgrade firebase versions to fix crash (#2646)

* fix: audio recording variety bugs (#2648)

* fix: variety of bugs in async audio feature

* fix: upload of empty messages and console.log cleanup

* fix: expo permission race conditions

* fix: create pure version of stopRecording() for usage on unmount

* fix: remove redundant export

* fix: actually amend failing test suites

* chore: remove constructors as they are not needed

* fix: pr remarks

* chore: write some simplistic functionality tests

* chore: return class instance rather than class itself for better usability

* chore: add more robust tests

* fix: linter errors

* fix: only display waveform whenever the mic is locked

* docs: add Deep Linking guide for the chat SDK (#2651)

* fix: change Block user action to Ban user action and UI cookbook for blocking users (#2649)

* fix: change Block user action to Ban user action

* fix: change Block user action to Ban user action

* fix: add back blockUser action and deprecate it

* docs: UI Cookbook for Blocking users

* chore(release): 5.36.1 [skip ci]

* chore(release): 1.28.1 [skip ci]

* fix: issue with loading app settings when the connectUser is not called on app (#2654)

* fix: issue with loading app settings when the connectUser is not called on app

* fix: add comments

* fix: add comments

* fix: unable to upload file due to special characters in the file name (#2656)

* fix: sdk size pr (#2657)

* [CI] Update SDK Size (#2653)

Co-authored-by: Khushal Agarwal <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1148-731.o3ts4yn1huletmfehy03vvfvxg.dx.internal.cloudapp.net>

* chore(release): 5.36.2 [skip ci]

* chore(release): 1.28.2 [skip ci]

* feat: add live location sharing cookbook (#2659)

* feat: add live location ui cookbook

* fix: prettier lint

* Update docusaurus/docs/reactnative/guides/live-location-sharing.mdx

Co-authored-by: Oliver Lazoroski <[email protected]>

* lint fixes

* fix lint issues

* fix locks

* move to ruby 3.1 and greater

---------

Co-authored-by: Oliver Lazoroski <[email protected]>

* chore(release): 5.37.0 [skip ci]

* chore(release): 1.29.0 [skip ci]

* fix: avoid prepending http before native supported url schemes (#2661)

* fix: avoid prepending http before native supported url schemes

* fix: move check to link parsing module

* fix: bad memoisation in window, screen dimension listener hooks (#2664)

* fix: bad memoisation in window, screen dimension listener hooks

* remove unused variable

* feat: add create chat client hook for easy usage (#2660)

* feat: add create chat client hook for easy usage

* docs: use useCreateChatClient hook for client creation

* fix: bump fastlane plugin version (#2665)

* fix: add theme properties for EmptyStateIndicator for message list (#2667)

* fix: add theme properties for EmptyStateIndicator for message list

* fix: update snapshots

* fix: apply card cover theme property order

* fix: pagination typescript errors and db synchronization bugs (#2669)

* fix: pagination typescript errors and db synchronization bugs

* chore: write test for db serialization issue

* fix: linter issues

* [CI] Bump max tolerance for sdk size analysis (#2674)

* chore: bump sample app version to v1.30.0

* fix: remove  nin and ne  operator usage in the SDK and the sample app (#2672)

* fix: remove  and  operator usage in the SDK and the sample app

* fix: remove console log

* fix: change console log to warn

* fix: add improvemnts

* fix: import of debouncefunc

* fix: import of debouncefunc

* fix: restructure queryMembers, queryUsers and ACItriggersettings

* fix: error bubbling for suggestions in auto complete input

* fix: request image access permissions for iOS only for native image picking (#2677)

* fix: properly resolve sendMessage during memoization (#2675)

* fix: properly resolve sendMessage during memoization

* fix: remedy change so that it does not cause performance issues

* chore: revert sendMessage in the dep array

* fix: deprecate messageReactions prop and use isMessageActionsVisible instead for messageActions (#2676)

* fix: deprecate messageReactions prop and use isMessageActionsVisible instead for messageActions

* docs: fix custom message actions

* fix: execution logic for showMessageOverlay

* chore(release): 5.38.0 [skip ci]

* chore(release): 1.29.1 [skip ci]

* fix: update yarn.lock for the project (#2681)

* fix: copy message action type for message actions (#2679)

* chore: update sdk size (#2678)

Co-authored-by: Khushal Agarwal <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1756-392.rxb2ubmju23uthz3oztawtjyeg.dx.internal.cloudapp.net>

* chore: resolve conflicts from develop

* fix: vale lint issues

* fix: new arch project config

---------

Co-authored-by: Ivan Sekovanikj <[email protected]>
Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: Alexey Alter-Pesotskiy <[email protected]>
Co-authored-by: Stream SDK Bot <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1148-731.o3ts4yn1huletmfehy03vvfvxg.dx.internal.cloudapp.net>
Co-authored-by: Santhosh Vaiyapuri <[email protected]>
Co-authored-by: Oliver Lazoroski <[email protected]>
Co-authored-by: Ivan Sekovanikj <[email protected]>
Co-authored-by: Stream Bot <runner@fv-az1756-392.rxb2ubmju23uthz3oztawtjyeg.dx.internal.cloudapp.net>
  • Loading branch information
10 people authored Sep 19, 2024
1 parent 36f2fe1 commit 8207356
Show file tree
Hide file tree
Showing 111 changed files with 4,678 additions and 2,086 deletions.
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

0 comments on commit 8207356

Please sign in to comment.