Skip to content

Commit

Permalink
Merge pull request #6 from cometchat-pro/V3.0.0-beta1
Browse files Browse the repository at this point in the history
updated to v3 SDK
  • Loading branch information
TirathBhuva authored Apr 5, 2021
2 parents f37771d + 2340403 commit 65fbb9b
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 88 deletions.
Binary file modified .DS_Store
Binary file not shown.
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</div>

<br/><br/>

# CometChat React Native UI Kit

</br></br>
Expand All @@ -21,9 +22,9 @@

</br></br>

CometChat React Native UI Kit is a collection of custom UI Components designed to build text chat and voice/video calling features in your application.
CometChat React Native UI Kit is a collection of custom UI Components designed to build text chat and voice/video calling features in your application.

The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly.
The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly.

---

Expand All @@ -39,9 +40,10 @@ Before you begin, ensure you have met the following requirements:

- [React-Native](https://reactnative.dev/docs/environment-setup)

|<div align="left"><span>**Note:**<span style="font-weight:500"> Support for Expo CLI based apps.</span> </span></div> |
|-----------------------------------------|
|If you are using Expo CLI to build a React Native app, the calling component will not work as our calling component needs native-level changes.However, you can create a React Native app using React Native CLI or use the 'expo eject' command to convert your app from an expo-managed workflow to a bare workflow.|
| <div align="left"><span>**Note:**<span style="font-weight:500"> Support for Expo CLI based apps.</span> </span></div> |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| If you are using Expo CLI to build a React Native app, the calling component will not work as our calling component needs native-level changes.However, you can create a React Native app using React Native CLI or use the 'expo eject' command to convert your app from an expo-managed workflow to a bare workflow. |

---

## Installing CometChat React Native UI Kit
Expand All @@ -58,7 +60,7 @@ To install React-Native UI Kit, you need to first register on CometChat Dashboar
### ii. Add the CometChat Dependency

```javascript
npm install @cometchat-pro/react-native-chat@2.2.1 --save
npm install @cometchat-pro/react-native-chat@3.0.0-beta1 --save
```

### iii. Other required DEPENDENCIES
Expand Down Expand Up @@ -88,7 +90,6 @@ These packages help make the ui-kit smooth and functioning
[emoji-mart-native](https://www.npmjs.com/package/emoji-mart-native)</br>
<br/>


## 2. Configure CometChat inside your app

### i. Initialize CometChat 🌟
Expand All @@ -97,7 +98,7 @@ The `init()` method initializes the settings required for CometChat.
We suggest calling the `init()` method on app startup, preferably in the `created()` method of the Application class.

```javascript
import {CometChat} from '@cometchat-pro/react-native-chat';
import { CometChat } from '@cometchat-pro/react-native-chat';

const appID = 'APP_ID';
const region = 'REGION';
Expand Down Expand Up @@ -126,7 +127,7 @@ CometChat.init(appID, appSetting).then(
This method takes `UID` and `Auth Key` as input parameters and returns the User object containing all the information of the logged-in user..

```javascript
import {CometChat} from '@cometchat-pro/react-native-chat';
import { CometChat } from '@cometchat-pro/react-native-chat';

const authKey = 'AUTH_KEY';
const uid = 'SUPERHERO1';
Expand All @@ -152,7 +153,7 @@ CometChat.login(uid, authKey).then(
## 3. Add UI Kit to your project

- Clone this repository.
- Copy the `cometchat-pro-react-native-ui-kit` folder to your source folder.
- Copy the `react-native-chat-ui-kit` folder to your source folder.
- Copy all the peer dependencies from package.json into your project's package.json and install them using `npm install`.

<br/>
Expand All @@ -165,18 +166,16 @@ Usage of application in project

```javascript
import React from 'react';
import {View} from 'react-native';
import {CometChatUI} from '../cometchat-pro-react-native-ui-kit';
import { View } from 'react-native';
import { CometChatUI } from '../cometchat-pro-react-native-ui-kit';

export default function CometChatUIView() {
return (
<View style={{flex: 1}}>
<View style={{ flex: 1 }}>
<CometChatUI />
</View>
);
}


```

---
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cometchat-pro-react-native-ui-kit",
"version": "2.2.1-1",
"version": "3.0.0-beta1-1",
"description": "Chat UI Kit for React Native App",
"main": "./src/index.js",
"scripts": {
Expand Down Expand Up @@ -48,8 +48,8 @@
"prettier": "^2.1.2"
},
"dependencies": {
"@cometchat-pro/react-native-calls": "1.0.8",
"@cometchat-pro/react-native-chat": "2.2.1",
"@cometchat-pro/react-native-calls": "2.0.1",
"@cometchat-pro/react-native-chat": "3.0.0-beta1",
"@react-native-community/async-storage": "^1.12.1",
"lodash": "^4.17.20",
"react-native-autolink": "^3.0.0",
Expand Down
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/components/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion src/components/Calls/CometChatIncomingCall/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default (props) => {
receiverType === 'user' ? message.sender.uid : message.receiverId;

if (Object.prototype.hasOwnProperty.call(message, 'readAt') === false) {
CometChat.markAsRead(message.id, receiverId, receiverType);
CometChat.markAsRead(message);
}
} catch (error) {
logger(error);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Calls/CometChatOutgoingCall/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class CometChatOutgoingCall extends React.PureComponent {
const id = type === 'user' ? message.sender.uid : message.receiverId;

if (Object.prototype.hasOwnProperty.call(message, 'readAt') === false) {
CometChat.markAsRead(message.id, id, type);
CometChat.markAsRead(message);
}
} catch (error) {
logger(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class CometChatConversationListWithMessages extends React.Component {
Object.prototype.hasOwnProperty.call(incomingCallMessage, readAt) ===
false
) {
CometChat.markAsRead(incomingCallMessage.id, receiverId, receiverType);
CometChat.markAsRead(incomingCallMessage);
}

// updating unread count in chats list
Expand Down
14 changes: 1 addition & 13 deletions src/components/Groups/CometChatGroupList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,19 +460,7 @@ class CometChatGroupList extends React.Component {

markMessagesRead = (message) => {
if (!(message.getReadAt() || message.getReadByMeAt())) {
if (message.getReceiverType() === CometChat.RECEIVER_TYPE.USER) {
CometChat.markAsRead(
message.getId().toString(),
message.getSender().getUid(),
message.getReceiverType(),
);
} else {
CometChat.markAsRead(
message.getId().toString(),
message.getReceiverId(),
message.getReceiverType(),
);
}
CometChat.markAsRead(message);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ class CometChatGroupListWithMessages extends React.Component {
Object.prototype.hasOwnProperty.call(incomingCallMessage, 'readAt') ===
false
) {
CometChat.markAsRead(incomingCallMessage.id, receiverId, receiverType);
CometChat.markAsRead(incomingCallMessage);
}

const { item, type } = this.state;
Expand Down
60 changes: 8 additions & 52 deletions src/components/Messages/CometChatMessageList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,7 @@ class CometChatMessageList extends React.PureComponent {
message.getSender().getUid() !== user.getUid() &&
!message.getReadAt()
) {
if (
message.getReceiverType() === CometChat.RECEIVER_TYPE.USER
) {
CometChat.markAsRead(
message.getId().toString(),
message.getSender().getUid(),
message.getReceiverType(),
);
} else if (
message.getReceiverType() === CometChat.RECEIVER_TYPE.GROUP
) {
CometChat.markAsRead(
message.getId().toString(),
message.getReceiverId(),
message.getReceiverType(),
);
}
CometChat.markAsRead(message);
}
this.props.actionGenerated(actions.MESSAGE_READ, message);
});
Expand Down Expand Up @@ -417,11 +401,7 @@ class CometChatMessageList extends React.PureComponent {
message.getReceiverId() === this.props.item.guid
) {
if (!message.getReadAt()) {
CometChat.markAsRead(
message.getId().toString(),
message.getReceiverId(),
message.getReceiverType(),
);
CometChat.markAsRead(message);
}

this.props.actionGenerated(actions.MESSAGE_RECEIVED, [message]);
Expand All @@ -431,11 +411,7 @@ class CometChatMessageList extends React.PureComponent {
message.getSender().uid === this.props.item.uid
) {
if (!message.getReadAt()) {
CometChat.markAsRead(
message.getId().toString(),
message.getSender().uid,
message.getReceiverType(),
);
CometChat.markAsRead(message);
}

this.props.actionGenerated(actions.MESSAGE_RECEIVED, [message]);
Expand All @@ -458,11 +434,7 @@ class CometChatMessageList extends React.PureComponent {
message.getReceiverId() === this.props.item.guid
) {
if (!message.getReadAt()) {
CometChat.markAsRead(
message.getId().toString(),
message.getReceiverId(),
message.getReceiverType(),
);
CometChat.markAsRead(message);
}

if (Object.prototype.hasOwnProperty.call(message, 'metadata')) {
Expand All @@ -487,11 +459,7 @@ class CometChatMessageList extends React.PureComponent {
message.getSender().uid === this.props.item.uid
) {
if (!message.getReadAt()) {
CometChat.markAsRead(
message.getId().toString(),
message.getSender().uid,
message.getReceiverType(),
);
CometChat.markAsRead(message);
}

if (Object.prototype.hasOwnProperty.call(message, 'metadata')) {
Expand Down Expand Up @@ -560,11 +528,7 @@ class CometChatMessageList extends React.PureComponent {
message.getReceiverId() === this.props.item.guid
) {
if (!message.getReadAt()) {
CometChat.markAsRead(
message.getId().toString(),
message.getReceiverId(),
message.getReceiverType(),
);
CometChat.markAsRead(message);
}

this.props.actionGenerated(actions.CALL_UPDATED, message);
Expand All @@ -574,11 +538,7 @@ class CometChatMessageList extends React.PureComponent {
message.getSender().uid === this.props.item.uid
) {
if (!message.getReadAt()) {
CometChat.markAsRead(
message.getId().toString(),
message.getSender().uid,
message.getReceiverType(),
);
CometChat.markAsRead(message);
}

this.props.actionGenerated(actions.CALL_UPDATED, message);
Expand All @@ -604,11 +564,7 @@ class CometChatMessageList extends React.PureComponent {
message.getReceiver().guid === this.props.item.guid
) {
if (!message.getReadAt()) {
CometChat.markAsRead(
message.getId().toString(),
message.getReceiverId(),
message.getReceiverType(),
);
CometChat.markAsRead(message);
}

this.props.actionGenerated(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class CometChatUserListWithMessages extends React.Component {
Object.prototype.hasOwnProperty.call(incomingCallMessage, 'readAt') ===
false
) {
CometChat.markAsRead(incomingCallMessage.id, receiverId, receiverType);
CometChat.markAsRead(incomingCallMessage);
}

const { item, type } = this.state;
Expand Down

0 comments on commit 65fbb9b

Please sign in to comment.