Skip to content

Commit f4c4640

Browse files
authored
Merge pull request #45 from cometchat-pro/v3.0.2-1
v3.0.2-1
2 parents 3bdbdc0 + b763463 commit f4c4640

File tree

13 files changed

+174
-3867
lines changed

13 files changed

+174
-3867
lines changed

CometChatWorkspace/cometchat-app/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
// }
1111
ext {
1212
buildToolsVersion = "29.0.2"
13-
minSdkVersion = 21
13+
minSdkVersion = 24
1414
compileSdkVersion = 29
1515
targetSdkVersion = 29
1616
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ To install React-Native UI Kit, you need to first register on CometChat Dashboar
6161

6262
```javascript
6363

64-
npm install @cometchat-pro/react-native-chat@3.0.0 --save
64+
npm install @cometchat-pro/react-native-chat@3.0.2 --save
6565

6666
```
6767

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

Lines changed: 0 additions & 3796 deletions
This file was deleted.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cometchat-pro-react-native-ui-kit",
3-
"version": "3.0.0-1",
3+
"version": "3.0.2-1",
44
"description": "Chat UI Kit for React Native App",
55
"main": "./src/index.js",
66
"scripts": {
@@ -50,8 +50,8 @@
5050
"prettier": "^2.1.2"
5151
},
5252
"dependencies": {
53-
"@cometchat-pro/react-native-calls": "2.0.3-beta1",
54-
"@cometchat-pro/react-native-chat": "3.0.0",
53+
"@cometchat-pro/react-native-calls": "2.1.1",
54+
"@cometchat-pro/react-native-chat": "3.0.2",
5555
"@react-native-async-storage/async-storage": "^1.13.4",
5656
"lodash": "^4.17.20",
5757
"react-native-autolink": "^3.0.0",

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React from 'react';
33
import { MessageHeaderManager } from './controller';
44
import { View, Text, TouchableOpacity, Image } from 'react-native';
5+
56
import { CometChatUserPresence, CometChatAvatar } from '../../Shared';
67
import * as enums from '../../../utils/enums';
78
import * as actions from '../../../utils/actions';
@@ -37,10 +38,14 @@ class CometChatMessageHeader extends React.Component {
3738
}
3839

3940
checkRestrictions = async () => {
40-
let isGroupVideoCallEnabled = await this.context.FeatureRestriction.isGroupVideoCallEnabled();
41-
let isOneOnOneAudioCallEnabled = await this.context.FeatureRestriction.isOneOnOneAudioCallEnabled();
42-
let isTypingIndicatorsEnabled = await this.context.FeatureRestriction.isTypingIndicatorsEnabled();
43-
let isOneOnOneVideoCallEnabled = await this.context.FeatureRestriction.isOneOnOneVideoCallEnabled();
41+
let isGroupVideoCallEnabled =
42+
await this.context.FeatureRestriction.isGroupVideoCallEnabled();
43+
let isOneOnOneAudioCallEnabled =
44+
await this.context.FeatureRestriction.isOneOnOneAudioCallEnabled();
45+
let isTypingIndicatorsEnabled =
46+
await this.context.FeatureRestriction.isTypingIndicatorsEnabled();
47+
let isOneOnOneVideoCallEnabled =
48+
await this.context.FeatureRestriction.isOneOnOneVideoCallEnabled();
4449
this.setState({
4550
restrictions: {
4651
isGroupVideoCallEnabled,
@@ -172,6 +177,7 @@ class CometChatMessageHeader extends React.Component {
172177
) {
173178
this.setState({ status: item.status, presence: item.status });
174179
}
180+
this.props.actionGenerated(actions.STATUS_UPDATED, item.status);
175181
break;
176182
}
177183
case enums.GROUP_MEMBER_KICKED:

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ class CometChatMessages extends React.PureComponent {
375375
break;
376376
case enums.TRANSIENT_MESSAGE_RECEIVED:
377377
this.liveReactionReceived(messages);
378+
break;
379+
case actions.STATUS_UPDATED:
380+
this.setState({ user: { ...this.state.user, status: messages } });
381+
378382
break;
379383
default:
380384
break;

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

Lines changed: 65 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
/* eslint-disable react/jsx-fragments */
22
import React from 'react';
3-
import { View, Text, TouchableOpacity, Image, ScrollView } from 'react-native';
3+
import {
4+
View,
5+
Text,
6+
TouchableOpacity,
7+
ScrollView,
8+
FlatList,
9+
} from 'react-native';
10+
import FastImage from 'react-native-fast-image';
411
import theme from '../../../resources/theme';
512
import Icon from 'react-native-vector-icons/MaterialIcons';
613
import style from './styles';
@@ -130,49 +137,71 @@ class CometChatStickerKeyboard extends React.PureComponent {
130137

131138
let stickers = null;
132139
if (Object.keys(this.state.stickerSet).length) {
133-
const sectionItems = Object.keys(this.state.stickerSet).map(
134-
(sectionItem, key) => {
135-
const stickerSetThumbnail = this.state.stickerSet[sectionItem][0]
136-
.stickerUrl;
137-
return (
138-
<TouchableOpacity
139-
key={key}
140-
style={style.sectionListItemStyle}
141-
onPress={() => this.onStickerSetClicked(sectionItem)}>
142-
<Image
143-
source={{ uri: stickerSetThumbnail }}
144-
alt={sectionItem}
145-
style={style.stickerHeaderImageStyle}
146-
/>
147-
</TouchableOpacity>
148-
);
149-
},
140+
const sectionItems = (
141+
<FlatList
142+
style={{
143+
width: '100%',
144+
flexDirection: 'row',
145+
backgroundColor: 'red',
146+
}}
147+
nestedScrollEnabled
148+
style={{ paddingVertical: 10 }}
149+
horizontal
150+
bounces={false}
151+
showsHorizontalScrollIndicator={false}
152+
data={Object.keys(this.state.stickerSet)}
153+
renderItem={({ item: sectionItem, index: key }) => {
154+
const stickerSetThumbnail =
155+
this.state.stickerSet[sectionItem][0].stickerUrl;
156+
157+
return (
158+
<TouchableOpacity
159+
key={sectionItem}
160+
style={style.sectionListItemStyle}
161+
onPress={() => this.onStickerSetClicked(sectionItem)}>
162+
<FastImage
163+
source={{ uri: stickerSetThumbnail }}
164+
alt={sectionItem}
165+
style={style.stickerHeaderImageStyle}
166+
/>
167+
</TouchableOpacity>
168+
);
169+
}}
170+
/>
150171
);
151172

152173
let activeStickerList = [];
153174
if (this.state.activeStickerList.length) {
154175
const stickerList = [...this.state.activeStickerList];
155-
activeStickerList = stickerList.map((stickerItem, key) => {
156-
return (
157-
<TouchableOpacity
158-
key={key}
159-
style={style.stickerItemStyle}
160-
onPress={() => this.sendStickerMessage(stickerItem)}>
161-
<Image
162-
source={{ uri: stickerItem.stickerUrl }}
163-
alt={stickerItem.stickerName}
164-
style={style.stickerImageStyle}
165-
/>
166-
</TouchableOpacity>
167-
);
168-
});
176+
activeStickerList = (
177+
<FlatList
178+
numColumns={3}
179+
style={{
180+
width: '100%',
181+
alignSelf: 'center',
182+
}}
183+
data={stickerList}
184+
renderItem={({ item: stickerItem, index: key }) => {
185+
return (
186+
<TouchableOpacity
187+
key={stickerItem.stickerName}
188+
style={style.stickerItemStyle}
189+
onPress={() => this.sendStickerMessage(stickerItem)}>
190+
<FastImage
191+
source={{ uri: stickerItem.stickerUrl }}
192+
alt={stickerItem.stickerName}
193+
style={style.stickerImageStyle}
194+
/>
195+
</TouchableOpacity>
196+
);
197+
}}
198+
/>
199+
);
169200
}
170201

171202
stickers = (
172203
<>
173-
<ScrollView bounces={false}>
174-
<View style={style.stickerListStyle}>{activeStickerList}</View>
175-
</ScrollView>
204+
<View style={style.stickerListStyle}>{activeStickerList}</View>
176205

177206
<View
178207
style={[
@@ -182,13 +211,7 @@ class CometChatStickerKeyboard extends React.PureComponent {
182211
backgroundColor: this.viewTheme.backgroundColor.silver,
183212
},
184213
]}>
185-
<ScrollView
186-
style={{ paddingVertical: 10 }}
187-
horizontal
188-
bounces={false}
189-
showsHorizontalScrollIndicator={false}>
190-
{sectionItems}
191-
</ScrollView>
214+
{sectionItems}
192215
</View>
193216
</>
194217
);

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Messages/CometChatStickerKeyboard/styles.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export default StyleSheet.create({
2424
marginHorizontal: 8,
2525
},
2626
stickerItemStyle: {
27-
minWidth: 50,
27+
width: '30%',
2828
minHeight: 50,
29-
maxWidth: 70,
29+
marginLeft: '2.5%',
3030
maxHeight: 70,
3131
flexShrink: 0,
3232
marginRight: 20,
@@ -37,8 +37,10 @@ export default StyleSheet.create({
3737
flexWrap: 'wrap',
3838
justifyContent: 'space-between',
3939
alignItems: 'center',
40-
paddingLeft: 20,
40+
// paddingHorizontal: 20,
41+
paddingRight: '2.5%',
4142
paddingBottom: 10,
43+
flex: 1,
4244
},
4345
stickerSectionListStyle: {
4446
borderTopWidth: 1,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { CometChat } from '@cometchat-pro/react-native-chat';
2+
import * as enums from '../../../utils/enums';
3+
4+
export class UserDetailManager {
5+
userListenerId = 'user_detail_' + new Date().getTime();
6+
7+
attachListeners(callback) {
8+
CometChat.addUserListener(
9+
this.userListenerId,
10+
new CometChat.UserListener({
11+
onUserOnline: (onlineUser) => {
12+
/* when someuser/friend comes online, user will be received here */
13+
callback(enums.USER_ONLINE, onlineUser);
14+
},
15+
onUserOffline: (offlineUser) => {
16+
/* when someuser/friend went offline, user will be received here */
17+
callback(enums.USER_OFFLINE, offlineUser);
18+
},
19+
}),
20+
);
21+
}
22+
23+
removeListeners() {
24+
CometChat.removeUserListener(this.userListenerId);
25+
}
26+
}

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Users/CometChatUserDetails/index.js

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22
import { View, Text, TouchableOpacity, Dimensions, Modal } from 'react-native';
3+
import { UserDetailManager } from './controller';
4+
import * as enums from '../../../utils/enums';
35
import theme from '../../../resources/theme';
46
import Icon from 'react-native-vector-icons/MaterialIcons';
57
import {
@@ -30,24 +32,63 @@ export default class CometChatUserDetails extends React.Component {
3032
}
3133

3234
componentDidMount() {
33-
this.setStatusForUser();
3435
this.checkRestrictions();
36+
this.setStatusForUser();
37+
this.UserDetailManager = new UserDetailManager();
38+
this.UserDetailManager.attachListeners(this.updateUser);
3539
}
3640

41+
updateUser = (key, user) => {
42+
console.log('updateUser', key, user);
43+
switch (key) {
44+
case enums.USER_ONLINE:
45+
case enums.USER_OFFLINE: {
46+
if (
47+
this.props.type === CometChat.ACTION_TYPE.TYPE_USER &&
48+
this.props.item.uid === user.uid
49+
) {
50+
//if user presence feature is disabled
51+
if (this.state.isUserPresenceEnabled === false) {
52+
return false;
53+
}
54+
55+
let status = '';
56+
if (user.status === CometChat.USER_STATUS.OFFLINE) {
57+
status = 'OFFLINE';
58+
} else if (user.status === CometChat.USER_STATUS.ONLINE) {
59+
status = 'ONLINE';
60+
}
61+
62+
this.setState({ status: status });
63+
}
64+
break;
65+
}
66+
default:
67+
break;
68+
}
69+
};
70+
3771
/**
3872
* Update bottom sheet to 0th snap point if prop received as open
3973
*/
4074
componentDidUpdate(prevProps) {
4175
if (!prevProps.open && this.props.open) {
4276
this.sheetRef.current.snapTo(0);
4377
}
78+
if (JSON.stringify(prevProps.item) !== JSON.stringify(this.props.item)) {
79+
this.setStatusForUser();
80+
}
4481
}
4582

4683
checkRestrictions = async () => {
47-
let isSharedMediaEnabled = await this.context.FeatureRestriction.isSharedMediaEnabled();
48-
let isBlockUserEnabled = await this.context.FeatureRestriction.isBlockUserEnabled();
49-
let isViewProfileEnabled = await this.context.FeatureRestriction.isViewProfileEnabled();
50-
let isUserPresenceEnabled = await this.context.FeatureRestriction.isUserPresenceEnabled();
84+
let isSharedMediaEnabled =
85+
await this.context.FeatureRestriction.isSharedMediaEnabled();
86+
let isBlockUserEnabled =
87+
await this.context.FeatureRestriction.isBlockUserEnabled();
88+
let isViewProfileEnabled =
89+
await this.context.FeatureRestriction.isViewProfileEnabled();
90+
let isUserPresenceEnabled =
91+
await this.context.FeatureRestriction.isUserPresenceEnabled();
5192
this.setState({
5293
restrictions: {
5394
isSharedMediaEnabled,
@@ -127,7 +168,7 @@ export default class CometChatUserDetails extends React.Component {
127168
this.props.item.blockedByMe &&
128169
!this.state.restrictions?.isUserPresenceEnabled ? null : (
129170
<CometChatUserPresence
130-
status={this.props.item.status}
171+
status={this.state.status}
131172
style={{ top: 35 }}
132173
cornerRadius={9}
133174
borderColor={theme.borderColor.white}

0 commit comments

Comments
 (0)