Skip to content

Commit 78d78d5

Browse files
authored
Merge pull request #31 from cometchat-pro/v2
V2
2 parents c1d7ce8 + 9e378f4 commit 78d78d5

File tree

52 files changed

+1219
-377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1219
-377
lines changed

CometChatWorkspace/cometchat-app/App.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ const App = () => {
5050
.build();
5151

5252
useEffect(() => {
53-
console.log('init***');
54-
CometChat.init(COMETCHAT_CONSTANTS.APP_ID, appSetting).catch(() => {
55-
return null;
56-
});
53+
CometChat.init(COMETCHAT_CONSTANTS.APP_ID, appSetting)
54+
.then(() => {
55+
if (CometChat.setSource) {
56+
CometChat.setSource('ui-kit', Platform.OS, 'react-native');
57+
}
58+
})
59+
.catch(() => {
60+
return null;
61+
});
5762

5863
if (Platform.OS === 'android') {
5964
setDefaultFontFamily();

CometChatWorkspace/cometchat-app/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.example">
3-
3+
44
<uses-permission android:name="android.permission.INTERNET" />
55

66
<application

CometChatWorkspace/cometchat-app/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ allprojects {
3636
// Android JSC is installed from npm
3737
url("$rootDir/../node_modules/jsc-android/dist")
3838
}
39-
maven {
40-
url "https://dl.bintray.com/cometchat/pro"
39+
maven {
40+
url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/"
4141
}
4242

4343
google()

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ To install React-Native UI Kit, you need to first register on CometChat Dashboar
6060
### ii. Add the CometChat Dependency
6161

6262
```javascript
63-
npm install @cometchat-pro/react-native-chat@2.3.0 --save
63+
npm install @cometchat-pro/react-native-chat@2.3.3 --save
6464
```
6565

6666
### iii. Other required DEPENDENCIES
@@ -89,6 +89,8 @@ These packages help make the ui-kit smooth and functioning
8989
[react-native-screens](https://www.npmjs.com/package/react-native-screens)</br>
9090
[emoji-mart-native](https://www.npmjs.com/package/emoji-mart-native)</br>
9191
[react-native-keep-awake](https://www.npmjs.com/package/react-native-keep-awake)</br>
92+
[react-native-webview](https://www.npmjs.com/package/react-native-webview)</br>
93+
9294

9395
<br/>
9496

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "cometchat-pro-react-native-ui-kit",
3-
"version": "2.3.0-2",
3+
4+
"version": "2.3.3-1",
5+
6+
47
"description": "Chat UI Kit for React Native App",
58
"main": "./src/index.js",
69
"scripts": {
@@ -49,9 +52,9 @@
4952
"prettier": "^2.1.2"
5053
},
5154
"dependencies": {
52-
"@cometchat-pro/react-native-calls": "2.0.1",
53-
"@cometchat-pro/react-native-chat": "2.3.0",
54-
"@react-native-community/async-storage": "^1.12.1",
55+
"@cometchat-pro/react-native-calls": "2.0.3-beta1",
56+
"@cometchat-pro/react-native-chat": "2.3.3",
57+
"@react-native-async-storage/async-storage": "^1.13.4",
5558
"lodash": "^4.17.20",
5659
"react-native-autolink": "^3.0.0",
5760
"redux": "^4.0.5",

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Chats/CometChatConversationListItem/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ class CometChatConversationListItem extends React.Component {
2525
this.state = {
2626
lastMessage: '',
2727
lastMessageTimestamp: '',
28+
isThreaded: false,
2829
};
2930
}
3031

3132
componentDidMount() {
3233
const message = this.getLastMessage();
3334
const timestamp = this.getLastMessageTimestamp();
3435

35-
this.setState({ lastMessage: message, lastMessageTimestamp: timestamp });
36+
this.setState({
37+
lastMessage: message || '',
38+
lastMessageTimestamp: timestamp,
39+
});
3640
}
3741

3842
componentDidUpdate(prevProps) {
@@ -45,7 +49,7 @@ class CometChatConversationListItem extends React.Component {
4549
const timestamp = this.getLastMessageTimestamp();
4650

4751
this.setState({
48-
lastMessage: message,
52+
lastMessage: message || '',
4953
lastMessageTimestamp: timestamp,
5054
});
5155
}
@@ -228,6 +232,7 @@ class CometChatConversationListItem extends React.Component {
228232
getMessage = (lastMessage) => {
229233
try {
230234
let message = null;
235+
this.setState({ isThreaded: lastMessage.parentMessageId });
231236
switch (lastMessage.type) {
232237
case CometChat.MESSAGE_TYPE.TEXT:
233238
message = lastMessage.text;
@@ -374,7 +379,10 @@ class CometChatConversationListItem extends React.Component {
374379
alignItems: 'center',
375380
}}>
376381
<Text numberOfLines={1} style={styles.itemLastMsgTimeStyle}>
377-
{this.state.lastMessage}
382+
383+
{`${this.state.isThreaded ? 'In a thread : ' : ''}` +
384+
this.state.lastMessage}
385+
378386
</Text>
379387
<CometChatBadgeCount
380388
theme={this.props.theme}

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Chats/CometChatConversationListWithMessages/index.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,24 +181,7 @@ class CometChatConversationListWithMessages extends React.Component {
181181
});
182182
break;
183183
case actions.DIRECT_CALL_ENDED:
184-
this.setState(
185-
{ joinDirectCall: false, ongoingDirectCall: null },
186-
() => {
187-
this.props.navigation.navigate(
188-
enums.NAVIGATION_CONSTANTS.COMET_CHAT_MESSAGES,
189-
{
190-
theme: this.theme,
191-
item: { ...this.state.item },
192-
tab: this.state.tab,
193-
type: this.state.type,
194-
composedThreadMessage: this.state.composedThreadMessage,
195-
callMessage: this.state.callMessage,
196-
loggedInUser: this.loggedInUser,
197-
actionGenerated: this.actionHandler,
198-
},
199-
);
200-
},
201-
);
184+
this.setState({ joinDirectCall: false, ongoingDirectCall: null });
202185

203186
break;
204187
case actions.ACCEPT_DIRECT_CALL:

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Groups/CometChatAddGroupMemberList/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class CometChatAddGroupMemberList extends React.Component {
276276
this.props.actionGenerated('addGroupParticipants', membersToAdd);
277277
}
278278
})
279-
.catch(() => {
279+
.catch((error) => {
280280
const errorCode = error?.message || 'ERROR';
281281
this.dropDownAlertRef?.showMessage('error', errorCode);
282282
logger('addMembersToGroup failed with exception:', error);

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Groups/CometChatGroupDetails/index.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react';
44
import { View, Text, TouchableOpacity, Dimensions, Modal } from 'react-native';
55
import theme from '../../../resources/theme';
66
import Icon from 'react-native-vector-icons/MaterialIcons';
7-
import { CometChatSharedMedia } from '../../Shared';
7+
import { CometChatSharedMedia, CometChatAvatar } from '../../Shared';
88
import style from './styles';
99
import BottomSheet from 'reanimated-bottom-sheet';
1010
import { CometChat } from '@cometchat-pro/react-native-chat';
@@ -21,6 +21,7 @@ import {
2121
import { deviceHeight } from '../../../utils/consts';
2222
import { logger } from '../../../utils/common';
2323
import DropDownAlert from '../../Shared/DropDownAlert';
24+
import styles from '../../Shared/CometChatAvatar/styles';
2425

2526
const ADD_MEMBER = 'addMember';
2627
const VIEW_MEMBER = 'viewMember';
@@ -739,6 +740,18 @@ export default class CometChatGroupDetails extends React.Component {
739740
);
740741
}
741742

743+
let avatar = (
744+
<View style={style.avatarStyle}>
745+
<CometChatAvatar
746+
cornerRadius={32}
747+
borderColor={theme.color.secondary}
748+
borderWidth={1}
749+
image={{ uri: this.props.item.avatar }}
750+
name={this.props.item.name}
751+
/>
752+
</View>
753+
);
754+
742755
return (
743756
<Modal
744757
transparent
@@ -785,6 +798,20 @@ export default class CometChatGroupDetails extends React.Component {
785798
</TouchableOpacity>
786799
<Text style={style.headerTitleStyle}>Details</Text>
787800
</View>
801+
<View style={styles.groupDetailContainer}>
802+
{avatar}
803+
<View style={styles.groupDetail}>
804+
<View>
805+
<Text style={style.userName}>
806+
{this.props.item.name}
807+
</Text>
808+
</View>
809+
<Text style={style.statusText} numberOfLines={1}>
810+
{parseInt(this.props.item?.membersCount)} Members
811+
</Text>
812+
</View>
813+
</View>
814+
788815
<View style={style.detailContainer}>
789816
{members}
790817
{options}

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Groups/CometChatGroupDetails/styles.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,29 @@ export default StyleSheet.create({
4343
overflow: 'hidden',
4444
minHeight: Dimensions.get('window').height - 80,
4545
},
46+
userName: {
47+
fontSize: 18 * heightRatio,
48+
color: theme.color.primary,
49+
fontWeight: 'bold',
50+
},
51+
statusText: {
52+
fontSize: 14,
53+
color: theme.color.blue,
54+
},
55+
avatarStyle: {
56+
width: 48,
57+
height: 48,
58+
borderRadius: 24,
59+
backgroundColor: 'rgba(51,153,255,0.25)',
60+
},
61+
groupDetailContainer: {
62+
padding: 16,
63+
flexDirection: 'row',
64+
alignItems: 'center',
65+
},
66+
groupDetail: {
67+
paddingLeft: 8,
68+
justifyContent: 'center',
69+
height: 48,
70+
},
4671
});

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Groups/CometChatGroupListWithMessages/index.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,7 @@ class CometChatGroupListWithMessages extends React.Component {
214214
});
215215
break;
216216
case actions.DIRECT_CALL_ENDED:
217-
this.setState(
218-
{ joinDirectCall: false, ongoingDirectCall: null },
219-
() => {
220-
this.props.navigation.navigate(
221-
enums.NAVIGATION_CONSTANTS.COMET_CHAT_MESSAGES,
222-
{
223-
theme: this.theme,
224-
item: { ...this.state.item },
225-
tab: this.state.tab,
226-
type: this.state.type,
227-
composedThreadMessage: this.state.composedThreadMessage,
228-
callMessage: this.state.callMessage,
229-
loggedInUser: this.loggedInUser,
230-
actionGenerated: this.actionHandler,
231-
},
232-
);
233-
},
234-
);
217+
this.setState({ joinDirectCall: false, ongoingDirectCall: null });
235218
break;
236219
case actions.ACCEPT_DIRECT_CALL:
237220
this.setState({ joinDirectCall: true }, () => {

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Messages/CometChatDeleteMessageBubble/index.js

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { View, Text } from 'react-native';
2+
import { View, Text, Platform } from 'react-native';
33
import theme from '../../../resources/theme';
44
import style from './style';
55
import * as enums from '../../../utils/enums';
@@ -9,14 +9,38 @@ import { CometChatAvatar } from '../../Shared';
99
const CometChatDeleteMessageBubble = (props) => {
1010
const message = { ...props.message, messageFrom: props.messageOf };
1111
let messageContainer = null;
12-
const timestamp = new Date(props.message.sentAt * 1000).toLocaleTimeString(
13-
'en-US',
14-
{
15-
hour: 'numeric',
16-
minute: 'numeric',
17-
hour12: true,
18-
},
19-
);
12+
13+
let timestamp = new Date(
14+
props.message.sentAt
15+
? props.message.sentAt * 1000
16+
: props.message._composedAt,
17+
).toLocaleTimeString('en-US', {
18+
hour: 'numeric',
19+
minute: 'numeric',
20+
hour12: true,
21+
});
22+
if (Platform.OS === 'android') {
23+
let time = timestamp.split(':'); // convert to array
24+
25+
// fetch
26+
var hours = Number(time[0]);
27+
var minutes = Number(time[1]?.split(' ')[0]);
28+
29+
// calculate
30+
var timeValue;
31+
32+
if (hours > 0 && hours <= 12) {
33+
timeValue = '' + hours;
34+
} else if (hours > 12) {
35+
timeValue = '' + (hours - 12);
36+
} else if (hours == 0) {
37+
timeValue = '12';
38+
}
39+
40+
timeValue += minutes < 10 ? ':0' + minutes : ':' + minutes; // get minutes
41+
timeValue += hours >= 12 ? ' PM' : ' AM'; // get AM/PM
42+
timestamp = timeValue;
43+
}
2044
const viewTheme = { ...theme, ...props.theme };
2145

2246
if (props.messageOf === enums.MESSAGE_OF_SENDER) {

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Messages/CometChatDeleteMessageBubble/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
22
import { widthRatio } from '../../../utils/consts';
33

44
export default StyleSheet.create({
5-
messageContainerStyle: { marginBottom: 16 },
5+
messageContainerStyle: { marginBottom: 16, marginHorizontal: 8 },
66
messageSenderNameContainerStyle: { marginBottom: 5 },
77
messageContainerForReceiver: {
88
flexDirection: 'row',

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Messages/CometChatMessageActions/actions.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ import { CometChat } from '@cometchat-pro/react-native-chat';
1616
const actionIconSize = 26;
1717

1818
export default (props) => {
19+
let sendMessage = null;
20+
if (
21+
props.message.messageFrom === enums.MESSAGE_FROM_RECEIVER &&
22+
props.message.receiverType === CometChat.RECEIVER_TYPE.GROUP
23+
) {
24+
sendMessage = (
25+
<TouchableOpacity
26+
style={styles.action}
27+
onPress={() =>
28+
props.actionGenerated(actions.SEND_MESSAGE, props.message)
29+
}>
30+
<FeatherIcon name="message-circle" size={actionIconSize} />
31+
<Text style={styles.actionsText}>Send Message Privately</Text>
32+
</TouchableOpacity>
33+
);
34+
}
1935
let threadedChats = (
2036
<TouchableOpacity
2137
style={styles.action}
@@ -47,7 +63,11 @@ export default (props) => {
4763
);
4864

4965
// if deleting messages need to be disabled
50-
if (props.message.messageFrom === 'receiver') {
66+
if (
67+
props.message.messageFrom === enums.MESSAGE_FROM_RECEIVER &&
68+
props.item.scope !== CometChat.GROUP_MEMBER_SCOPE.ADMIN &&
69+
props.item.scope !== CometChat.GROUP_MEMBER_SCOPE.MODERATOR
70+
) {
5171
deleteMessage = null;
5272
}
5373
let editMessage = (
@@ -76,6 +96,7 @@ export default (props) => {
7696
return (
7797
<TouchableWithoutFeedback onPress={() => {}}>
7898
<View style={styles.actionsContainer}>
99+
{sendMessage}
79100
{threadedChats}
80101
{editMessage}
81102
{deleteMessage}

0 commit comments

Comments
 (0)