Skip to content

Commit 5f63ae7

Browse files
Merge pull request #24 from MirrorFly/release_sdk/V2.3.4
release sdk version 2.3.4
2 parents f267d91 + 459fe27 commit 5f63ae7

File tree

136 files changed

+2096
-1046
lines changed

Some content is hidden

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

136 files changed

+2096
-1046
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ mirrorfly-uikit-react-native-*.tgz
8989
!.yarn/versions
9090

9191
patches/react-native-network-logger+1.16.1.patch
92+
93+
# Ignore lock files
94+
**/*.lock

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"jest": "^29.6.3",
4848
"lodash-es": "^4.17.21",
4949
"luxon": "^3.5.0",
50-
"mirrorfly-reactnative-sdk": "^2.3.0",
50+
"mirrorfly-reactnative-sdk": "^2.3.4",
5151
"moment": "^2.30.1",
5252
"patch-package": "^8.0.0",
5353
"prettier": "2.8.8",

patches/react-native-contacts+8.0.4.patch

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

src/Helper/Calls/Call.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,22 @@ const updateCallAgainScreenData = (userID, callType) => {
242242
Store.dispatch(setCallModalScreen(CALL_AGAIN_SCREEN));
243243
};
244244

245+
export const disconnectCall = async () => {
246+
setpreventMultipleClick(false);
247+
clearOutgoingTimer();
248+
SDK.endCall();
249+
stopOutgoingCallRingingTone();
250+
if (Platform.OS === 'android') {
251+
await stopForegroundServiceNotification();
252+
}
253+
dispatchDisconnected();
254+
clearIosCallListeners();
255+
endCallForIos();
256+
resetCallData();
257+
closeCallModalActivity(true);
258+
};
259+
260+
245261
export const endCall = async (isFromTimeout = false, userId = '', callType = '') => {
246262
setpreventMultipleClick(false);
247263
const { data: confrenceData = {} } = Store.getState().showConfrenceData || {};
@@ -500,7 +516,7 @@ export const selectLargeVideoUser = (userJid, volumelevel) => {
500516
if (!volumeLevelsBasedOnUserJid[userJid]) {
501517
volumeLevelsBasedOnUserJid[userJid] = 0.5;
502518
}
503-
volumeLevelsInDBBasedOnUserJid[userJid] = volumelevel ? volumelevel : 0;
519+
volumeLevelsInDBBasedOnUserJid[userJid] = volumelevel || 0;
504520
if (Object.keys(volumeLevelsInDBBasedOnUserJid).length > 1) {
505521
let largest = Object.values(volumeLevelsInDBBasedOnUserJid)[0];
506522
userJid = Object.keys(volumeLevelsInDBBasedOnUserJid)[0];
@@ -622,7 +638,7 @@ function getFromJidFromRemoteStream(remoteStream) {
622638

623639
export const switchCallData = (callType, res) => {
624640
const callerUUID = Store.getState().callData.callerUUID || {};
625-
const isSpeakerEnabled = callType === CALL_TYPE_VIDEO ? true : false;
641+
const isSpeakerEnabled = callType === CALL_TYPE_VIDEO;
626642
enableSpeaker(callerUUID, isSpeakerEnabled);
627643
if (Platform.OS === 'android') {
628644
stopForegroundServiceNotification().then(() => {

src/Media/AudioPlayer.js

Lines changed: 65 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import commonStyles from '../styles/commonStyles';
1212
import RNSlider from './RNSlider';
1313
import style from './styles';
1414
import { useFocusEffect } from '@react-navigation/native';
15+
import PropTypes from 'prop-types';
1516

1617
const PLAY_STATE_PAUSED = 'paused';
1718
const PLAY_STATE_PLAYING = 'playing';
@@ -22,6 +23,15 @@ export const pauseAudio = () => {
2223
soundRef?.current?.updateState?.();
2324
};
2425

26+
const propTypes = {
27+
mediaStatus: PropTypes.string,
28+
uri: PropTypes.string,
29+
msgId: PropTypes.string,
30+
media: PropTypes.shape({
31+
duration: PropTypes.number, // Ensures media.duration is a number
32+
}),
33+
};
34+
2535
const AudioPlayer = props => {
2636
const { media, msgId, uri, mediaStatus } = props;
2737
const [playState, setPlayState] = React.useState(PLAY_STATE_PAUSED);
@@ -41,12 +51,7 @@ const AudioPlayer = props => {
4151

4252
React.useEffect(() => {
4353
let timeout = setInterval(() => {
44-
if (
45-
sound.current &&
46-
sound?.current?.isLoaded() &&
47-
playStateRef.current === PLAY_STATE_PLAYING &&
48-
!sliderEditing.current
49-
) {
54+
if (sound?.current?.isLoaded() && playStateRef.current === PLAY_STATE_PLAYING && !sliderEditing.current) { //NOSONAR
5055
sound.current.getCurrentTime(seconds => {
5156
setPlaySeconds(seconds);
5257
});
@@ -72,40 +77,49 @@ const AudioPlayer = props => {
7277
}, [appState]);
7378

7479
React.useEffect(() => {
75-
if (sound.current && playState === PLAY_STATE_PLAYING) {
76-
if (soundRef.current && soundRef.current.msgId !== msgId) {
77-
soundRef.current.pause();
78-
soundRef?.current?.updateState?.();
79-
}
80+
const initializeSound = filepath => {
81+
Sound.setCategory('Playback');
82+
sound.current = new Sound(filepath, '', error => {
83+
if (error) {
84+
console.log(error, 'Play Error');
85+
setPlayState(PLAY_STATE_PAUSED);
86+
} else {
87+
handleSoundLoaded();
88+
}
89+
});
90+
};
91+
92+
const handleSoundLoaded = () => {
93+
setPlayState(PLAY_STATE_PLAYING);
94+
playStateRef.current = PLAY_STATE_PLAYING;
95+
setTimeout(() => {
96+
configureSoundRef();
97+
sound.current.setCurrentTime(playSeconds);
98+
sound.current.play(playComplete);
99+
});
100+
};
101+
102+
const configureSoundRef = () => {
80103
soundRef.current = sound.current;
81104
soundRef.current.msgId = msgId;
82105
soundRef.current.updateState = () => {
83106
setPlayState(PLAY_STATE_PAUSED);
84107
};
85-
sound.current.play(playComplete);
86-
} else {
87-
const filepath = uri;
88-
if (playState === PLAY_STATE_LOADING && filepath) {
89-
Sound.setCategory('Playback');
90-
sound.current = new Sound(filepath, '', error => {
91-
if (error) {
92-
console.log(error, 'Play Error');
93-
setPlayState(PLAY_STATE_PAUSED);
94-
} else {
95-
setPlayState(PLAY_STATE_PLAYING);
96-
playStateRef.current = PLAY_STATE_PLAYING;
97-
setTimeout(() => {
98-
soundRef.current = sound.current;
99-
soundRef.current.msgId = msgId;
100-
soundRef.current.updateState = () => {
101-
setPlayState(PLAY_STATE_PAUSED);
102-
};
103-
sound.current.setCurrentTime(playSeconds);
104-
sound.current.play(playComplete);
105-
});
106-
}
107-
});
108+
};
109+
110+
const handlePlayStatePlaying = () => {
111+
if (soundRef.current && soundRef.current.msgId !== msgId) {
112+
soundRef.current.pause();
113+
soundRef?.current?.updateState?.();
108114
}
115+
configureSoundRef();
116+
sound.current.play(playComplete);
117+
};
118+
119+
if (sound.current && playState === PLAY_STATE_PLAYING) {
120+
handlePlayStatePlaying();
121+
} else if (playState === PLAY_STATE_LOADING && uri) {
122+
initializeSound(uri);
109123
}
110124
}, [playState]);
111125

@@ -144,12 +158,22 @@ const AudioPlayer = props => {
144158
setPlayState(PLAY_STATE_PAUSED);
145159
};
146160

147-
const getAudioTimeString = seconds => {
148-
let h = Math.floor(seconds / 3600);
149-
let m = Math.floor((seconds % 3600) / 60);
150-
let s = Math.floor(seconds % 60);
161+
const getAudioTimeString = totalSeconds => {
162+
let h = Math.floor(totalSeconds / 3600);
163+
let m = Math.floor((totalSeconds % 3600) / 60);
164+
let s = Math.floor(totalSeconds % 60);
165+
166+
let hours = '';
167+
if (h > 0) {
168+
hours = h < 10 ? `0${h}` : h;
169+
hours += ':';
170+
}
171+
let minutes = m < 10 ? `0${m}` : m;
172+
let seconds = s < 10 ? `0${s}` : s;
173+
174+
minutes += ':';
151175

152-
return (h > 0 ? (h < 10 ? `0${h}` : h) + ':' : '') + (m < 10 ? `0${m}` : m) + ':' + (s < 10 ? `0${s}` : s);
176+
return hours + minutes + seconds;
153177
};
154178

155179
const playComplete = success => {
@@ -215,4 +239,6 @@ const AudioPlayer = props => {
215239
);
216240
};
217241

242+
AudioPlayer.propTypes = propTypes;
243+
218244
export default AudioPlayer;

src/Media/ImageZoom.js

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

src/Media/RNSlider.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default class Slider extends PureComponent {
171171
value: new Animated.Value(this.props.value),
172172
};
173173

174-
componentWillMount() {
174+
componentWillMount() { // NOSONAR
175175
this._panResponder = PanResponder.create({
176176
onStartShouldSetPanResponder: this._handleStartShouldSetPanResponder,
177177
onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder,
@@ -183,7 +183,7 @@ export default class Slider extends PureComponent {
183183
});
184184
}
185185

186-
componentWillReceiveProps(nextProps) {
186+
componentWillReceiveProps(nextProps) { // NOSONAR
187187
const newValue = nextProps.value;
188188

189189
if (this.props.value !== newValue) {
@@ -400,9 +400,11 @@ export default class Slider extends PureComponent {
400400

401401
_setCurrentValueAnimated = value => {
402402
const animationType = this.props.animationType;
403-
const animationConfig = Object.assign({}, DEFAULT_ANIMATION_CONFIGS[animationType], this.props.animationConfig, {
403+
const animationConfig = {
404+
...DEFAULT_ANIMATION_CONFIGS[animationType],
405+
...this.props.animationConfig,
404406
toValue: value,
405-
});
407+
};
406408

407409
Animated[animationType](this.state.value, animationConfig).start();
408410
};
@@ -430,7 +432,7 @@ export default class Slider extends PureComponent {
430432
const { width, height } = this._getTouchOverflowSize();
431433

432434
const touchOverflowStyle = {};
433-
if (width !== undefined && height !== undefined) {
435+
if (width !== undefined && height !== undefined) { //NOSONAR
434436
const verticalMargin = -height / 2;
435437
touchOverflowStyle.marginTop = verticalMargin;
436438
touchOverflowStyle.marginBottom = verticalMargin;
@@ -482,6 +484,14 @@ export default class Slider extends PureComponent {
482484
};
483485
}
484486

487+
Slider.propTypes = {
488+
...Slider.propTypes,
489+
styles: PropTypes.object,
490+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
491+
trackStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
492+
thumbStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
493+
};
494+
485495
const defaultStyles = StyleSheet.create({
486496
container: {
487497
height: 40,

src/Media/VideoPlayer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useAppState } from '../common/hooks';
88
import { showToast } from '../helpers/chatHelpers';
99
import commonStyles from '../styles/commonStyles';
1010
import MediaControls, { PLAYER_STATES } from './media-controls';
11+
import { sdkLog } from '../SDK/utils';
1112

1213
const VideoPlayer = () => {
1314
const {
@@ -145,6 +146,7 @@ const VideoPlayer = () => {
145146
};
146147

147148
const onError = error => {
149+
sdkLog('VIDEO_PLAY_BACK_ERROR', error);
148150
showToast(error?.error?.errorException);
149151
handlePause();
150152
setIsLoading(false);
@@ -174,7 +176,6 @@ const VideoPlayer = () => {
174176
paused={paused}
175177
controls={false}
176178
poster={videoUri}
177-
posterResizeMode={'contain'}
178179
ref={videoPlayer}
179180
resizeMode={'contain'}
180181
source={{ uri: videoUri }}

src/Media/media-controls/MediaControls.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export type Props = {
1212
duration: number;
1313
fadeOutDisable?: boolean;
1414
fadeOutDelay?: number;
15-
isFullScreen: boolean;
1615
isLoading: boolean;
1716
primaryColor: string;
1817
onFullScreen?: (event: GestureResponderEvent) => void;

src/Navigation/stackNavigation.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createNativeStackNavigator } from '@react-navigation/native-stack';
2+
import PropTypes from 'prop-types';
23
import React from 'react';
34
import { Provider } from 'react-redux';
45
import VideoPlayer from '../Media/VideoPlayer';
@@ -113,6 +114,10 @@ export function ChatScreen({ chatUser }) {
113114
);
114115
}
115116

117+
ChatScreen.propTypes = {
118+
chatUser: PropTypes.string,
119+
};
120+
116121
export const ProfileStack = () => {
117122
return (
118123
<Provider store={store}>

0 commit comments

Comments
 (0)