Skip to content

Commit 3bdbdc0

Browse files
authored
Merge pull request #42 from cometchat-pro/v3.0.0-1
v3 stable release
2 parents 4608c2b + a09126a commit 3bdbdc0

File tree

18 files changed

+604
-465
lines changed

18 files changed

+604
-465
lines changed

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-beta5 --save
64+
npm install @cometchat-pro/react-native-chat@3.0.0 --save
6565

6666
```
6767

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"name": "cometchat-pro-react-native-ui-kit",
3-
4-
"version": "3.0.0-beta5-1",
5-
3+
"version": "3.0.0-1",
64
"description": "Chat UI Kit for React Native App",
75
"main": "./src/index.js",
86
"scripts": {
@@ -52,11 +50,9 @@
5250
"prettier": "^2.1.2"
5351
},
5452
"dependencies": {
55-
5653
"@cometchat-pro/react-native-calls": "2.0.3-beta1",
57-
"@cometchat-pro/react-native-chat": "3.0.0-beta5",
54+
"@cometchat-pro/react-native-chat": "3.0.0",
5855
"@react-native-async-storage/async-storage": "^1.13.4",
59-
6056
"lodash": "^4.17.20",
6157
"react-native-autolink": "^3.0.0",
6258
"redux": "^4.0.5",

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Calls/CometChatOutgoingCall/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class CometChatOutgoingCall extends React.PureComponent {
3232

3333
this.callScreenManager = null;
3434
this.theme = { ...theme, ...this.props.theme };
35+
3536
this.outgoingAlert = new Sound(outgoingCallAlert);
3637
}
3738

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Calls/CometChatOutgoingDirectCall/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class CometChatOutgoingDirectCall extends React.Component {
9191
this.props.close();
9292
},
9393
onError: (error) => {
94+
props.actionGenerated(actions.CALL_ERROR, error);
95+
9496
console.log('Call Error: ', error);
9597
},
9698
});

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

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class CometChatConversationList extends React.Component {
4444
};
4545
this.chatListRef = React.createRef();
4646
this.theme = { ...theme, ...this.props.theme };
47+
Sound.setCategory('Ambient', true);
4748
this.audio = new Sound(incomingOtherMessageAlert);
4849
this.UIKitSettingsBuilder = new UIKitSettings();
4950
}
@@ -76,7 +77,8 @@ class CometChatConversationList extends React.Component {
7677
}
7778

7879
checkRestrictions = async () => {
79-
let isMessagesSoundEnabled = await this.context.FeatureRestriction.isMessagesSoundEnabled();
80+
let isMessagesSoundEnabled =
81+
await this.context.FeatureRestriction.isMessagesSoundEnabled();
8082
this.setState({ isMessagesSoundEnabled });
8183
};
8284

@@ -183,11 +185,8 @@ class CometChatConversationList extends React.Component {
183185
const message = this.props.messageToMarkRead;
184186
this.makeConversation(message)
185187
.then((response) => {
186-
const {
187-
conversationKey,
188-
conversationObj,
189-
conversationList,
190-
} = response;
188+
const { conversationKey, conversationObj, conversationList } =
189+
response;
191190

192191
if (conversationKey > -1) {
193192
const unreadMessageCount = this.makeUnreadMessageCount(
@@ -341,6 +340,7 @@ class CometChatConversationList extends React.Component {
341340
case enums.MEDIA_MESSAGE_RECEIVED:
342341
case enums.CUSTOM_MESSAGE_RECEIVED:
343342
this.updateConversation(message);
343+
this.markMessageAsDelivered(message);
344344
break;
345345
case enums.MESSAGE_EDITED:
346346
case enums.MESSAGE_DELETED:
@@ -375,6 +375,21 @@ class CometChatConversationList extends React.Component {
375375
logger(error);
376376
}
377377
};
378+
markMessageAsDelivered = (message) => {
379+
try {
380+
if (
381+
message.sender?.uid !== this.loggedInUser?.uid &&
382+
message.hasOwnProperty('deliveredAt') === false
383+
) {
384+
CometChat.markAsDelivered(message);
385+
}
386+
} catch (error) {
387+
console.log(
388+
'[CometChatConversationList markMessageAsDelivered] faailed to mark as deivered =',
389+
message,
390+
);
391+
}
392+
};
378393

379394
/**
380395
* Handle update user details in existing conversation object
@@ -584,9 +599,8 @@ class CometChatConversationList extends React.Component {
584599
const { conversationKey, conversationObj, conversationList } = response;
585600

586601
if (conversationKey > -1) {
587-
const unreadMessageCount = this.makeUnreadMessageCount(
588-
conversationObj,
589-
);
602+
const unreadMessageCount =
603+
this.makeUnreadMessageCount(conversationObj);
590604
const lastMessageObj = this.makeLastMessage(message, conversationObj);
591605

592606
const conversationWithObj = { ...conversationObj.conversationWith };
@@ -654,9 +668,8 @@ class CometChatConversationList extends React.Component {
654668
conversationList.splice(conversationKey, 1);
655669
this.setState({ conversationList: conversationList });
656670
} else {
657-
const unreadMessageCount = this.makeUnreadMessageCount(
658-
conversationObj,
659-
);
671+
const unreadMessageCount =
672+
this.makeUnreadMessageCount(conversationObj);
660673
const lastMessageObj = this.makeLastMessage(
661674
message,
662675
conversationObj,
@@ -700,9 +713,8 @@ class CometChatConversationList extends React.Component {
700713
const { conversationKey, conversationObj, conversationList } = response;
701714

702715
if (conversationKey > -1) {
703-
const unreadMessageCount = this.makeUnreadMessageCount(
704-
conversationObj,
705-
);
716+
const unreadMessageCount =
717+
this.makeUnreadMessageCount(conversationObj);
706718
const lastMessageObj = this.makeLastMessage(message, conversationObj);
707719

708720
const conversationWithObj = { ...conversationObj.conversationWith };
@@ -749,9 +761,8 @@ class CometChatConversationList extends React.Component {
749761
const { conversationKey, conversationObj, conversationList } = response;
750762
if (conversationKey > -1) {
751763
if (options && this.loggedInUser.uid !== options.user.uid) {
752-
const unreadMessageCount = this.makeUnreadMessageCount(
753-
conversationObj,
754-
);
764+
const unreadMessageCount =
765+
this.makeUnreadMessageCount(conversationObj);
755766
const lastMessageObj = this.makeLastMessage(
756767
message,
757768
conversationObj,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react';
22
import theme from '../../../resources/theme';
33
import CometChatUserPresence from '../../Shared/CometChatUserPresence';
4-
import CometChatAvatar from '../../Shared/CometChatUserPresence';
4+
import CometChatAvatar from '../../Shared/CometChatAvatar';
55

66
import { Text, View, Image, TouchableOpacity } from 'react-native';
77
import style from './styles';

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { Dimensions, View, Animated } from 'react-native';
55
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
66
import { logger } from '../../../utils/common';
77
import styles from './styles';
8-
8+
import * as enums from '../../../utils/enums';
9+
import { CometChat } from '@cometchat-pro/react-native-chat';
910
const { height: deviceHeight } = Dimensions.get('window');
1011

1112
const ANIMATION_END_Y = Math.ceil(deviceHeight * 0.5);
@@ -28,6 +29,7 @@ class AnimatedHeart extends Component {
2829
this.state = {
2930
position: new Animated.Value(0),
3031
};
32+
3133
this._yAnimation = this.state.position.interpolate({
3234
inputRange: [NEGATIVE_END_Y, 0],
3335
outputRange: [ANIMATION_END_Y, 0],
@@ -171,6 +173,8 @@ export default class CometChatLiveReactions extends Component {
171173
return (
172174
<AnimatedHeart
173175
key={v.id}
176+
item={this.props.item}
177+
type={this.props.type}
174178
// eslint-disable-next-line react/jsx-no-bind
175179
onComplete={this.removeHeart.bind(this, v.id)}
176180
style={{

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Messages/CometChatMessageComposer/composerActions.js

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ export default class ComposerActions extends Component {
2727
super(props);
2828
this.state = {
2929
restrictions: null,
30+
snapPoints: null,
3031
};
3132
}
3233
componentDidUpdate(prevProps) {
3334
if (!prevProps.visible && this.props.visible) {
34-
this.sheetRef.current.snapTo(0);
35+
this.sheetRef?.current?.snapTo(0);
3536
}
3637
}
3738

@@ -40,16 +41,33 @@ export default class ComposerActions extends Component {
4041
}
4142
checkRestrictions = async () => {
4243
let isPollsEnabled = await this.context.FeatureRestriction.isPollsEnabled();
43-
let isStickersEnabled = await this.context.FeatureRestriction.isStickersEnabled();
44+
let isStickersEnabled =
45+
await this.context.FeatureRestriction.isStickersEnabled();
4446
let isFilesEnabled = await this.context.FeatureRestriction.isFilesEnabled();
45-
let isPhotosVideosEnabled = await this.context.FeatureRestriction.isPhotosVideosEnabled();
47+
let isPhotosVideosEnabled =
48+
await this.context.FeatureRestriction.isPhotosVideosEnabled();
49+
let height = 0;
50+
if (isPollsEnabled) {
51+
height++;
52+
}
53+
if (isStickersEnabled) {
54+
height++;
55+
}
56+
if (isFilesEnabled) {
57+
height++;
58+
}
59+
if (isPhotosVideosEnabled) {
60+
height += 4;
61+
}
62+
4663
this.setState({
4764
restrictions: {
4865
isPollsEnabled,
4966
isStickersEnabled,
5067
isFilesEnabled,
5168
isPhotosVideosEnabled,
5269
},
70+
snapPoints: [height * 60 * heightRatio, 0],
5371
});
5472
};
5573

@@ -79,7 +97,7 @@ export default class ComposerActions extends Component {
7997
cameraType: 'back',
8098
},
8199
(response) => {
82-
this.sheetRef.current.snapTo(1);
100+
this.sheetRef?.current?.snapTo(1);
83101
this.props.close();
84102
if (response.didCancel) {
85103
return null;
@@ -122,7 +140,7 @@ export default class ComposerActions extends Component {
122140
);
123141
}
124142
} catch (err) {
125-
this.sheetRef.current.snapTo(1);
143+
this.sheetRef?.current?.snapTo(1);
126144
this.props.close();
127145
}
128146
};
@@ -158,7 +176,7 @@ export default class ComposerActions extends Component {
158176
? CometChat.MESSAGE_TYPE.IMAGE
159177
: CometChat.MESSAGE_TYPE.VIDEO,
160178
);
161-
this.sheetRef.current.snapTo(1);
179+
this.sheetRef?.current?.snapTo(1);
162180
this.props.close();
163181
},
164182
);
@@ -175,7 +193,7 @@ export default class ComposerActions extends Component {
175193
uri: res.uri,
176194
};
177195
this.props.sendMediaMessage(file, CometChat.MESSAGE_TYPE.FILE);
178-
this.sheetRef.current.snapTo(1);
196+
this.sheetRef?.current?.snapTo(1);
179197
this.props.close();
180198
} catch (err) {
181199
if (DocumentPicker.isCancel(err)) {
@@ -313,24 +331,26 @@ export default class ComposerActions extends Component {
313331
<View style={style.bottomSheetContainer}>
314332
<TouchableWithoutFeedback
315333
onPress={() => {
316-
this.sheetRef.current.snapTo(1);
334+
this.sheetRef?.current?.snapTo(1);
317335
this.props.close();
318336
}}>
319337
<View style={style.fullFlex}>
320-
<BottomSheet
321-
ref={this.sheetRef}
322-
snapPoints={[400 * heightRatio, 0]}
323-
borderRadius={30}
324-
initialSnap={1}
325-
enabledInnerScrolling={false}
326-
enabledContentTapInteraction
327-
overdragResistanceFactor={10}
328-
renderContent={this.renderContent}
329-
renderHeader={this.renderHeader}
330-
onCloseEnd={() => {
331-
close();
332-
}}
333-
/>
338+
{this.state.snapPoints ? (
339+
<BottomSheet
340+
ref={this.sheetRef}
341+
snapPoints={this.state.snapPoints}
342+
borderRadius={30}
343+
initialSnap={1}
344+
enabledInnerScrolling={false}
345+
enabledContentTapInteraction
346+
overdragResistanceFactor={10}
347+
renderContent={this.renderContent}
348+
renderHeader={this.renderHeader}
349+
onCloseEnd={() => {
350+
close();
351+
}}
352+
/>
353+
) : null}
334354
</View>
335355
</TouchableWithoutFeedback>
336356
</View>

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

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class CometChatMessageComposer extends React.PureComponent {
6262
keyboardActivity: false,
6363
restrictions: null,
6464
};
65-
65+
Sound.setCategory('Ambient', true);
6666
this.audio = new Sound(outgoingMessageAlert);
6767
CometChat.getLoggedinUser()
6868
.then((user) => (this.loggedInUser = user))
@@ -85,9 +85,12 @@ export default class CometChatMessageComposer extends React.PureComponent {
8585
}
8686

8787
checkRestrictions = async () => {
88-
let isLiveReactionsEnabled = await this.context.FeatureRestriction.isLiveReactionsEnabled();
89-
let isTypingIndicatorsEnabled = await this.context.FeatureRestriction.isTypingIndicatorsEnabled();
90-
let isSmartRepliesEnabled = await this.context.FeatureRestriction.isSmartRepliesEnabled();
88+
let isLiveReactionsEnabled =
89+
await this.context.FeatureRestriction.isLiveReactionsEnabled();
90+
let isTypingIndicatorsEnabled =
91+
await this.context.FeatureRestriction.isTypingIndicatorsEnabled();
92+
let isSmartRepliesEnabled =
93+
await this.context.FeatureRestriction.isSmartRepliesEnabled();
9194
this.setState({
9295
restrictions: {
9396
isLiveReactionsEnabled,
@@ -588,16 +591,32 @@ export default class CometChatMessageComposer extends React.PureComponent {
588591
sendReaction = (event) => {
589592
const typingInterval = 1000;
590593

591-
const typingMetadata = {
592-
type: enums.LIVE_REACTION_KEY,
593-
reaction: this.props.reaction,
594-
};
594+
// const typingMetadata = {
595+
// type: enums.LIVE_REACTION_KEY,
596+
// reaction: this.props.reaction,
597+
// };
595598

596-
this.startTyping(typingInterval, typingMetadata);
599+
// this.startTyping(typingInterval, typingMetadata);
600+
try {
601+
const metadata = {
602+
type: enums.METADATA_TYPE_LIVEREACTION,
603+
reaction: this.props.reactionName || 'heart',
604+
};
605+
606+
const { receiverId, receiverType } = this.getReceiverDetails();
607+
let transientMessage = new CometChat.TransientMessage(
608+
receiverId,
609+
receiverType,
610+
metadata,
611+
);
612+
CometChat.sendTransientMessage(transientMessage);
613+
} catch (err) {
614+
console.log(err);
615+
}
597616
this.props.actionGenerated(actions.SEND_REACTION);
598617
event.persist();
599618
setTimeout(() => {
600-
this.endTyping(typingMetadata);
619+
// this.endTyping(typingMetadata);
601620
this.props.actionGenerated(actions.STOP_REACTION);
602621
}, typingInterval);
603622
};

0 commit comments

Comments
 (0)