From d599070d9fab5eca03b32df0f36470e2c5b1dfda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B9=D0=BB=D0=BE=20=D0=9C=D0=BE?= =?UTF-8?q?=D0=B3=D0=B8=D0=BB=D1=8E=D0=BA?= Date: Fri, 29 Oct 2021 10:11:44 +0300 Subject: [PATCH] Media messages open in modals --- .../main/java/com/ethora/MainApplication.java | 1 + android/settings.gradle | 2 + ios/Podfile | 2 + package.json | 8 +- src/Screens/chat.js | 366 ++++++++++++------ src/Screens/chatHome.js | 6 +- src/components/AudioPlayer/AudioPlayer.js | 161 ++++++++ src/components/AudioPlayer/PlayButton.js | 30 ++ src/helpers/xmppCentral.js | 92 ++--- src/routes.js | 2 +- yarn.lock | 88 ++++- 11 files changed, 551 insertions(+), 207 deletions(-) create mode 100644 src/components/AudioPlayer/AudioPlayer.js create mode 100644 src/components/AudioPlayer/PlayButton.js diff --git a/android/app/src/main/java/com/ethora/MainApplication.java b/android/app/src/main/java/com/ethora/MainApplication.java index fd16a82b3..5d827fc5c 100644 --- a/android/app/src/main/java/com/ethora/MainApplication.java +++ b/android/app/src/main/java/com/ethora/MainApplication.java @@ -4,6 +4,7 @@ import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; +import com.otomogroove.OGReactNativeWaveform.OGWavePackage; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; diff --git a/android/settings.gradle b/android/settings.gradle index f06626b2a..51ab87cf3 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,3 +1,5 @@ rootProject.name = 'ethora' +include ':react-native-audiowaveform' +project(':react-native-audiowaveform').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-audiowaveform/android') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' diff --git a/ios/Podfile b/ios/Podfile index 2ff158206..289e676e4 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -15,6 +15,8 @@ target 'ethora' do :hermes_enabled => false ) + pod 'OGReactNativeWaveform', :path => '../node_modules/react-native-audiowaveform' + target 'ethoraTests' do inherit! :complete # Pods for testing diff --git a/package.json b/package.json index 80c650a00..554c0af7f 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,13 @@ "dependencies": { "@invertase/react-native-apple-authentication": "^2.1.2", "@react-native-async-storage/async-storage": "^1.15.5", - "@react-native-clipboard/clipboard": "^1.8.4", + "@react-native-clipboard/clipboard": "^1.9.0", "@react-native-community/audio-toolkit": "^2.0.3", "@react-native-community/checkbox": "^0.5.8", "@react-native-community/masked-view": "^0.1.11", "@react-native-community/netinfo": "^6.0.0", "@react-native-community/push-notification-ios": "^1.8.0", + "@react-native-community/slider": "^4.1.10", "@react-native-community/viewpager": "^5.0.11", "@react-native-firebase/analytics": "^11.1.2", "@react-native-firebase/app": "^11.1.2", @@ -38,6 +39,7 @@ "react": "17.0.1", "react-native": "0.64.2", "react-native-audio-recorder-player": "^3.1.2", + "react-native-audiowaveform": "^2.0.5", "react-native-beautiful-video-recorder": "^2.0.1", "react-native-bootsplash": "^3.2.6", "react-native-camera": "^4.2.1", @@ -66,10 +68,14 @@ "react-native-share": "^6.2.1", "react-native-simple-toast": "^1.1.3", "react-native-skeleton-content-nonexpo": "^1.0.11", + "react-native-slider": "^0.11.0", "react-native-svg": "^12.0.3", "react-native-tab-view": "^2.14.0", "react-native-typing-animation": "^0.1.7", "react-native-vector-icons": "^8.1.0", + "react-native-video": "^5.2.0-alpha1", + "react-native-video-controls": "^2.8.1", + "react-native-video-player": "^0.12.0", "react-native-walkthrough-tooltip": "^1.2.0", "react-redux": "^7.2.4", "realm": "^10.8.0", diff --git a/src/Screens/chat.js b/src/Screens/chat.js index da88ceb57..ea602cd5d 100644 --- a/src/Screens/chat.js +++ b/src/Screens/chat.js @@ -18,7 +18,7 @@ import { } from 'react-native'; import emojiUtils from 'emoji-utils'; import {connect} from 'react-redux'; -import {GiftedChat, Actions} from 'react-native-gifted-chat'; +import {GiftedChat, Actions, Send} from 'react-native-gifted-chat'; import MessageBody from '../components/MessageBody'; import { loginUser, @@ -37,7 +37,7 @@ import { setRecentRealtimeChatAction, tokenAmountUpdateAction, updateMessageComposingState, - setCurrentChatDetails + setCurrentChatDetails, } from '../actions/chatAction'; import {queryRoomAllMessages} from '../components/realmModels/messages'; import { @@ -55,6 +55,7 @@ import Entypo from 'react-native-vector-icons/Entypo'; import AntDesign from 'react-native-vector-icons/AntDesign'; import Ionicons from 'react-native-vector-icons/Ionicons'; +import FontAwesome from 'react-native-vector-icons/FontAwesome'; import {updateRosterList} from '../components/realmModels/chatList'; import {TypingAnimation} from 'react-native-typing-animation'; @@ -79,8 +80,8 @@ import {updateMessageObject} from '../components/realmModels/messages'; import {commonColors, textStyles} from '../../docs/config'; import {RNCamera} from 'react-native-camera'; import VideoRecorder from 'react-native-beautiful-video-recorder'; -import parseChatLink from '../helpers/parseChatLink'; -import openChatFromChatLink from '../helpers/openChatFromChatLink'; +import VideoPlayer from 'react-native-video-player'; +import WaveForm from 'react-native-audiowaveform'; import Modal from 'react-native-modal'; import AudioRecorderPlayer, { @@ -90,8 +91,10 @@ import AudioRecorderPlayer, { AudioSet, AudioSourceAndroidType, } from 'react-native-audio-recorder-player'; +import Video from 'react-native-video'; +import AudioPlayer from '../components/AudioPlayer/AudioPlayer'; -const {primaryColor} = commonColors; +const {primaryColor, primaryDarkColor} = commonColors; const {boldFont, regularFont} = textStyles; const {xml} = require('@xmpp/client'); @@ -165,7 +168,10 @@ class Chat extends Component { currentPositionSec: 0, currentDurationSec: 0, recording: false, - videoModalOpen: false, + mediaContentModalVisible: false, + playingMessageId: '', + mediaModalContent: {type: '', localURL: '', remoteUrl: ''}, + videoPaused: false, }; this.audioRecorderPlayer = new AudioRecorderPlayer(); this.audioRecorderPlayer.setSubscriptionDuration(0.09); // optional. Default is 0.1 @@ -490,10 +496,9 @@ class Chat extends Component { }); const result = await this.audioRecorderPlayer.startRecorder(path); - this.setState({ - recording: true, - }); - console.log(result, 'sdfnksdfjlsdj;f'); + // this.setState({ + // recording: true, + // }); }; onStopRecord = async () => { // [{"fileCopyUri": "content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fhello.mp3", "name": "hello.mp3", "size": 84384, "type": "audio/mpeg", "uri": "content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fhello.mp3"}] @@ -982,32 +987,40 @@ class Chat extends Component { }; startDownload = props => { - const {isStoredFile, mimetype, localURL} = props.currentMessage; - console.log(localURL, 'LocalURL..........'); + const {isStoredFile, mimetype, localURL, realImageURL, id} = + props.currentMessage; var RNFS = require('react-native-fs'); + this.setState({ + mediaModalContent: { + type: mimetype, + url: localURL, + remoteUrl: realImageURL, + }, + mediaContentModalVisible: mimetype === 'audio/mpeg' ? false : true, + }); if (isStoredFile) { + this.setState({playingMessageId: id}); //display image from store location path on modal view RNFS.exists(localURL) .then(val => { - console.log('yesinhere', val); if (val) { if (Platform.OS === 'ios') { - try{ - RNFetchBlob.ios.openDocument('file://' + localURL); - }catch(err){ - console.log(err,"rnfetchblobcatch") + try { + RNFetchBlob.ios.openDocument('file://' + localURL); + } catch (err) { + console.log(err, 'rnfetchblobcatch'); } } if (Platform.OS === 'android') { - console.log(localURL, 'Asfadsfsfbvdfbdfghbdfghbfg'); - RNFetchBlob.android.actionViewIntent(localURL, mimetype); - - // if (mimetype === 'audio/mpeg') { - // new Player(localURL).play(); - // } else { - // RNFetchBlob.android.actionViewIntent(localURL, mimetype); - // } + console.log(mimetype, 'Asfadsfsfbvdfbdfghbdfghbfg'); + // RNFetchBlob.android.actionViewIntent(localURL, mimetype); + + if (mimetype === 'audio/mpeg') { + // new Player(realImageURL).play(); + } else { + RNFetchBlob.android.actionViewIntent(localURL, mimetype); + } } } else { this.downloadFunction(props); @@ -1063,30 +1076,59 @@ class Chat extends Component { }); } }; - RenderCam = () => { - return ( - - - - - ); + RenderMediaModalContent = () => { + if (this.state.mediaModalContent.type === 'image/jpeg') { + return ( + + this.toggleVideoModal(false)} + activeOpacity={0.9}> + + + + ); + } + if (this.state.mediaModalContent.type === 'video/mp4') { + return ( + + + this.setState({videoPaused: !this.state.videoPaused}) + } + activeOpacity={1} + style={{width: '100%', height: '100%'}}> + + + + ); + } + // if (this.state.mediaModalContent.type === 'audio/mpeg') { + // return ; + // } }; renderMessageImage = props => { - const {image, realImageURL, mimetype, size, duration} = + const {image, realImageURL, mimetype, size, duration, id} = props.currentMessage; + console.log(props.currentMessage, '234u2asdasda34'); let formatedSize = {size: 0, unit: 'KB'}; formatedSize = this.formatBytes(parseFloat(size), 2); - if (mimetype === 'video/mp4' || mimetype === 'image/jpeg' || mimetype === 'image/png' || mimetype === 'application/octet-stream') { + if ( + mimetype === 'video/mp4' || + mimetype === 'image/jpeg' || + mimetype === 'image/png' || + mimetype === 'application/octet-stream' + ) { return ( this.startDownload(props)} @@ -1098,43 +1140,47 @@ class Chat extends Component { justifyContent: 'center', position: 'relative', }}> - + - + + {formatedSize.size + ' ' + formatedSize.unit} + + + + {duration && ( + - - - {formatedSize.size + ' ' + formatedSize.unit} - - - - {duration && ( - - {duration} - - )} - + {duration} + + )} + ); } else if (mimetype === 'audio/mpeg') { + console.log(mimetype, '238942384923840'); // console.log(mimetype, props.currentMessage, 'aksdfdsfslsdjaasdasldasskld') return ( */} - {/* + {/* {formatedSize.size} {formatedSize.unit} */} - - + {/* {this.state.playingMessageId === id ? ( + - {duration && ( - - {duration} - - )} + ) : ( */} + + + + {/* )} */} + + {duration && ( + + )} {/* */} @@ -1226,6 +1293,41 @@ class Chat extends Component { } }; + renderSend = props => { + if (!props.text) { + return ( + + {/* {this.state.recording ? ( + + {} + + ) : ( */} + + + + {/* )} */} + + ); + } + return ; + }; + renderAttachment() { return ( @@ -1306,7 +1408,7 @@ class Chat extends Component { optionTintColor="#000000" /> - ( - {/* this.toggleVideoModal(true)} - // onPressIn={this.onStartRecord} - // onPressOut={this.onStopRecord} - > - - */} + {this.state.recording ? ( )} - /> + /> */} {/* { - this.setState({videoModalOpen: false}); + this.setState({mediaContentModalVisible: false}); }; toggleVideoModal = value => { - this.setState({videoModalOpen: value}); - setTimeout(() => { - this.videoRecord(); - }, 1000); + this.setState({mediaContentModalVisible: value}); }; shouldScrollTo(indexValue) { @@ -1413,11 +1505,16 @@ class Chat extends Component { } } - handleChatLinks=(chatLink)=>{ + handleChatLinks = chatLink => { const walletAddress = this.props.loginReducer.initialData.walletAddress; const chatJID = parseChatLink(chatLink); - openChatFromChatLink(chatJID, walletAddress, this.props.setCurrentChatDetails, this.props.navigation); - } + openChatFromChatLink( + chatJID, + walletAddress, + this.props.setCurrentChatDetails, + this.props.navigation, + ); + }; render() { return ( @@ -1427,6 +1524,9 @@ class Chat extends Component { onQRPressed={() => this.QRPressed()} navigation={this.props.navigation} /> + {this.state.mediaModalContent.type === 'audio/mpeg' && ( + + )} ( @@ -1452,6 +1552,7 @@ class Chat extends Component { shadowRadius: 3.84, elevation: 5, }} + renderSend={this.renderSend} renderChatFooter={() => this.chatFooter()} renderChatEmpty={() => emptyChatComponent()} isLoadingEarlier={this.state.isLoadingEarlier} @@ -1464,7 +1565,7 @@ class Chat extends Component { onSend={messageString => this.submitMessage(messageString, false)} user={{ _id: - this.state.manipulatedWalletAddress + '@' + xmppConstants.DOMAIN , + this.state.manipulatedWalletAddress + '@' + xmppConstants.DOMAIN, name: this.state.firstName + ' ' + this.state.lastName, }} onPressAvatar={props => this.onAvatarPress(props)} @@ -1473,18 +1574,18 @@ class Chat extends Component { onLongPress={(e, m) => this.onLongPressMessage(e, m)} onLongPressAvatar={e => this.onLongPressAvatar(e)} renderMessageImage={this.renderMessageImage} - parsePatterns={(linkStyle) => [ + parsePatterns={linkStyle => [ { - pattern:/\bhttps:\/\/www\.eto\.li\/go\?c=0x[0-9a-f]+_0x[0-9a-f]+/gm, - style:linkStyle, - onPress: this.handleChatLinks + pattern: + /\bhttps:\/\/www\.eto\.li\/go\?c=0x[0-9a-f]+_0x[0-9a-f]+/gm, + style: linkStyle, + onPress: this.handleChatLinks, }, { - pattern:/\bhttps:\/\/www\.eto\.li\/go\?c=[0-9a-f]+/gm, - style:linkStyle, - onPress: this.handleChatLinks + pattern: /\bhttps:\/\/www\.eto\.li\/go\?c=[0-9a-f]+/gm, + style: linkStyle, + onPress: this.handleChatLinks, }, - ]} /> { - Alert.alert('Modal has been closed.'); - }}> - {this.RenderCam()} + isVisible={this.state.mediaContentModalVisible} + style={{position: 'relative'}} + backdropOpacity={0.9} + onBackdropPress={this.onBackdropPress}> + <> + this.toggleVideoModal(false)}> + + + + {this.RenderMediaModalContent()} + ); @@ -1579,5 +1687,5 @@ module.exports = connect(mapStateToProps, { fetchTransaction, setOtherUserDetails, setIsPreviousUser, - setCurrentChatDetails + setCurrentChatDetails, })(Chat); diff --git a/src/Screens/chatHome.js b/src/Screens/chatHome.js index 13f1d2c76..97a893b8d 100644 --- a/src/Screens/chatHome.js +++ b/src/Screens/chatHome.js @@ -346,7 +346,7 @@ const RenderDragItem = ({ fontFamily: mediumFont, fontSize: hp('1.6%'), }} - onPress={() => onMenuItemPress(index, item.jid, 'rename')}> + onPress={() => onMenuItemPress(index, item.jid, 'rename', item.name)}> Rename )} @@ -615,7 +615,7 @@ class ChatHome extends Component { } } } - onMenuItemPress = (index, jid, type) => { + onMenuItemPress = (index, jid, type, name) => { const initialData = this.props.loginReducer.initialData; let walletAddress = initialData.walletAddress; const manipulatedWalletAddress = underscoreManipulation(walletAddress); @@ -630,7 +630,7 @@ class ChatHome extends Component { this.hideMenu(index); } if (type === 'rename') { - this.setState({modalVisible: true, pickedChatJid: jid}); + this.setState({modalVisible: true, pickedChatJid: jid, newChatName: name}); this.hideMenu(index); } if (type === 'move') { diff --git a/src/components/AudioPlayer/AudioPlayer.js b/src/components/AudioPlayer/AudioPlayer.js new file mode 100644 index 000000000..0a47dcc5e --- /dev/null +++ b/src/components/AudioPlayer/AudioPlayer.js @@ -0,0 +1,161 @@ +import React, {useEffect, useState} from 'react'; +import { + StyleSheet, + Text, + View, + Image, + SafeAreaView, + TouchableOpacity, +} from 'react-native'; +import Slider from 'react-native-slider'; +import FontAwesome from 'react-native-vector-icons/FontAwesome'; +import AudioRecorderPlayer from 'react-native-audio-recorder-player'; +import RNFetchBlob from 'rn-fetch-blob'; +import PlayButton from './PlayButton'; +import {commonColors, textStyles} from '../../../docs/config'; +const {primaryColor} = commonColors; + +export default function AudioPlayer({audioUrl}) { + const [isAlreadyPlay, setisAlreadyPlay] = useState(false); + const [duration, setDuration] = useState('00:00:00'); + const [timeElapsed, setTimeElapsed] = useState('00:00:00'); + const [percent, setPercent] = useState(0); + const [inprogress, setInprogress] = useState(false); + const [audioRecorderPlayer, setAudioRecordedPlayer] = useState( + new AudioRecorderPlayer(), + ); + + const changeTime = async seconds => { + // 50 / duration + let seektime = (seconds / 100) * duration; + setTimeElapsed(seektime); + audioRecorderPlayer.seekToPlayer(seektime); + }; + const onStartPress = async e => { + setisAlreadyPlay(true); + setInprogress(true); + audioRecorderPlayer.startPlayer(audioUrl); + audioRecorderPlayer.setVolume(1.0); + + audioRecorderPlayer.addPlayBackListener(async e => { + if (e.currentPosition === e.duration) { + audioRecorderPlayer.stopPlayer(); + setisAlreadyPlay(false); + } + let percent = Math.round( + (Math.floor(e.currentPosition) / Math.floor(e.duration)) * 100, + ); + setTimeElapsed(e.currentPosition); + setPercent(percent); + setDuration(e.duration); + }); + }; + + useEffect(() => { + onStartPress(); + return () => { + audioRecorderPlayer.stopPlayer(); + audioRecorderPlayer.removePlayBackListener(); + }; + }, [audioUrl]); + + const onPausePress = async e => { + console.log(audioUrl, 'auidaopd'); + + setisAlreadyPlay(false); + audioRecorderPlayer.pausePlayer(); + }; + + return ( + + + {!isAlreadyPlay ? ( + onStartPress()} state="play" /> + ) : ( + onPausePress()} state="pause" /> + )} + + + changeTime(seconds)} + value={percent} + /> + + + + {!inprogress + ? timeElapsed + : audioRecorderPlayer.mmssss(Math.floor(timeElapsed))} + + + {!inprogress + ? duration + : audioRecorderPlayer.mmssss(Math.floor(duration))} + + + + + ); +} + +const styles = StyleSheet.create({ + container: { + height: 50, + backgroundColor: primaryColor, + borderBottomLeftRadius: 5, + borderBottomRightRadius: 5, + justifyContent: 'flex-start', + alignItems: 'center', + flexDirection: 'row', + paddingHorizontal: 10, + paddingBottom: 5, + }, + textLight: { + color: 'rgba(255,255,255,1)', + }, + text: { + color: '#8E97A6', + }, + textDark: { + color: 'rgba(255,255,255,1)', + }, + buttonContainer: { + flexDirection: 'row', + justifyContent: 'flex-start', + alignItems: 'center', + }, + coverContainer: { + shadowColor: '#5D3F6A', + shadowOffset: {height: 15}, + shadowRadius: 8, + shadowOpacity: 0.3, + }, + + track: { + width: '100%', + height: 2, + borderRadius: 1, + backgroundColor: '#FFF', + }, + thumb: { + width: 8, + height: 8, + backgroundColor: commonColors.primaryDarkColor, + }, + timeStamp: { + fontSize: 11, + fontWeight: '500', + }, + seekbar: {margin: 32, width: '80%'}, + inprogress: { + marginTop: -12, + flexDirection: 'row', + justifyContent: 'space-between', + }, + trackname: {alignItems: 'center', marginTop: 32}, +}); diff --git a/src/components/AudioPlayer/PlayButton.js b/src/components/AudioPlayer/PlayButton.js new file mode 100644 index 000000000..4a987ba85 --- /dev/null +++ b/src/components/AudioPlayer/PlayButton.js @@ -0,0 +1,30 @@ +import React from 'react'; +import { StyleSheet, TouchableOpacity } from 'react-native'; +import FontAwesome from 'react-native-vector-icons/FontAwesome'; + +export default function PlayButton(props) { + return ( + + + + ); +} + +const styles = StyleSheet.create({ + playButtonContainer: { + // backgroundColor: '#000', + borderColor: 'rgba(93, 63, 106, 0.2)', + // borderWidth: 16, + width: 30, + height: 30, + borderRadius: 30, + alignItems: 'center', + justifyContent: 'center', + // marginHorizontal: 32, + shadowColor: '#5D3F6A', + // shadowRadius: 30, + shadowOpacity: 0.5, + }, +}); \ No newline at end of file diff --git a/src/helpers/xmppCentral.js b/src/helpers/xmppCentral.js index 5cb77c0b4..9a4bac5e5 100644 --- a/src/helpers/xmppCentral.js +++ b/src/helpers/xmppCentral.js @@ -8,7 +8,8 @@ import * as xmppConfig from '../constants/xmppConstants'; import { insertRosterList, fetchRosterList as fetchChatListRealm, - updateRosterList} from '../components/realmModels/chatList'; + updateRosterList, +} from '../components/realmModels/chatList'; import {insertMessages} from '../components/realmModels/messages'; import { fetchRosterlist, @@ -16,24 +17,24 @@ import { get_list_of_subscribers, commonDiscover, getRoomInfo, - updateVCard + updateVCard, } from './xmppStanzaRequestMessages'; import Toast from 'react-native-simple-toast'; -import { Alert } from 'react-native'; +import {Alert} from 'react-native'; import * as types from '../constants/types'; import {joinSystemMessage} from '../components/SystemMessage'; -const { client, xml } = require("@xmpp/client"); -const debug = require("@xmpp/debug"); +const {client, xml} = require('@xmpp/client'); +const debug = require('@xmpp/debug'); let profileDescription = ''; let profilePhoto = ''; let rolesMap = {}; -let usersLastSeen = {} +let usersLastSeen = {}; export let xmpp; -export const xmppListener=( +export const xmppListener = ( manipulatedWalletAddress, updatedRoster, initialData, @@ -47,8 +48,8 @@ export const xmppListener=( setRosterAction, setRecentRealtimeChatAction, setOtherUserDetails, - logOut -)=> { + logOut, +) => { debug(xmpp, true); xmpp.on('error', err => { @@ -242,13 +243,10 @@ export const xmppListener=( 'fdsmlfnsdddsdffslfmn', ); // stanza.children[1].children[1].children[0] === - // 'You have been banned from this room' && + // 'You have been banned from this room' && // Alert.alert(' You have been banned from this room'); if (stanza.children[1].attrs.code === '500') { - console.log( - stanza.children[1].children[1].children[0], - 'xmpperrorr', - ); + console.log(stanza.children[1].children[1].children[0], 'xmpperrorr'); xmpp.reconnect.stop(); } } @@ -258,11 +256,11 @@ export const xmppListener=( let role = stanza.children[0].children[0].attrs.role; rolesMap[roomJID] = role; - usersLastSeen[userJID] = moment().format('DD hh:mm') + usersLastSeen[userJID] = moment().format('DD hh:mm'); setRoomRoles(rolesMap); - console.log(usersLastSeen, 'reducadklsmads;kld') + console.log(usersLastSeen, 'reducadklsmads;kld'); await setOtherUserDetails({ - anotherUserLastSeen: usersLastSeen + anotherUserLastSeen: usersLastSeen, }); } @@ -290,8 +288,8 @@ export const xmppListener=( if (stanza.name === 'message') { //capture message composing if ( - stanza?.children[0]?.children[0]?.children[0]?.children[2] - ?.children[0]?.name === 'invite' + stanza?.children[0]?.children[0]?.children[0]?.children[2]?.children[0] + ?.name === 'invite' ) { let jid = stanza?.children[0]?.children[0]?.children[0]?.children[3]?.attrs @@ -300,8 +298,7 @@ export const xmppListener=( const subscribe = xml( 'iq', { - from: - manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, + from: manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, to: jid, type: 'set', id: 'inviteFromArchive', @@ -321,8 +318,7 @@ export const xmppListener=( const presence = xml( 'presence', { - from: - manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, + from: manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, to: jid + '/' + manipulatedWalletAddress, }, xml('x', 'http://jabber.org/protocol/muc'), @@ -337,8 +333,7 @@ export const xmppListener=( const subscribe = xml( 'iq', { - from: - manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, + from: manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, to: jid, type: 'set', id: xmppConfig.newSubscription, @@ -392,8 +387,7 @@ export const xmppListener=( const subscribe = xml( 'iq', { - from: - manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, + from: manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, to: jid, type: 'set', id: xmppConfig.newSubscription, @@ -437,7 +431,6 @@ export const xmppListener=( let size = ''; let duration = ''; - await singleMessageDetailArray.forEach(item => { if (item.name === 'body') { text = item.children[0]; @@ -465,12 +458,11 @@ export const xmppListener=( imageLocation = item.attrs.location; - imageLocationPreview = item.attrs.locationPreview; - + imageLocationPreview = item.attrs.locationPreview || item.attrs.location; mimetype = item.attrs.mimetype; + console.log(item, '3202394023-49-23') duration = item.attrs.duration; - size = item.attrs.size; } }); @@ -521,12 +513,7 @@ export const xmppListener=( }; } - insertMessages( - messageObject, - roomName, - tokenAmount, - receiverMessageId, - ); + insertMessages(messageObject, roomName, tokenAmount, receiverMessageId); } } @@ -611,8 +598,7 @@ export const xmppListener=( 'presence', { id: 'roomPresence', - from: - manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, + from: manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, to: item.attrs.jid + '/' + manipulatedWalletAddress, }, // xml('data', { @@ -623,16 +609,10 @@ export const xmppListener=( xmpp.send(presence); let message = joinSystemMessage({ - username: - initialData.firstName + - ' ' + - initialData.lastName, + username: initialData.firstName + ' ' + initialData.lastName, }); // this.submitMessage(message, item.attrs.jid); - get_list_of_subscribers( - item.attrs.jid, - manipulatedWalletAddress, - ); + get_list_of_subscribers(item.attrs.jid, manipulatedWalletAddress); setTimeout(function () { getRoomInfo(manipulatedWalletAddress, item.attrs.jid); }, 2000); @@ -642,8 +622,7 @@ export const xmppListener=( const subscribe = xml( 'iq', { - from: - manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, + from: manipulatedWalletAddress + '@' + xmppConfig.DOMAIN, to: nonMemberchat.name + xmppConfig.CONFERENCEDOMAIN, type: 'set', id: xmppConfig.newSubscription, @@ -722,7 +701,7 @@ export const xmppListener=( imageLocation = item.attrs.location; - imageLocationPreview = item.attrs.locationPreview; + imageLocationPreview = item.attrs.locationPreview || item.attrs.location; mimetype = item.attrs.mimetype; duration = item.attrs.duration; @@ -733,8 +712,6 @@ export const xmppListener=( if (isSystemMessage === 'false') { if (isMediafile) { - - messageObject = { _id: _messageId, text: '', @@ -794,17 +771,14 @@ export const xmppListener=( xmpp.reconnect.delay = 2000; xmpp.send(xml('presence')); - fetchRosterlist( - manipulatedWalletAddress, - xmppConfig.subscriptionsStanzaID, - ); + fetchRosterlist(manipulatedWalletAddress, xmppConfig.subscriptionsStanzaID); commonDiscover(manipulatedWalletAddress, xmppConfig.DOMAIN); vcardRetrievalRequest(manipulatedWalletAddress); }); -} +}; -export const xmppConnect=(walletAddress,password)=>{ +export const xmppConnect = (walletAddress, password) => { xmpp = client({ service: xmppConfig.SERVICE, domain: xmppConfig.DOMAIN, @@ -812,4 +786,4 @@ export const xmppConnect=(walletAddress,password)=>{ password: password, }); xmpp.start(); -} +}; diff --git a/src/routes.js b/src/routes.js index 77482e24b..b5261f9ac 100644 --- a/src/routes.js +++ b/src/routes.js @@ -712,4 +712,4 @@ module.exports = connect(mapStateToProps, { setRoomRoles, logOut, setOtherUserDetails -})(Routes); +})(Routes); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index f18c1c300..a426703aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -69,7 +69,6 @@ browserslist "^4.16.6" semver "^6.3.0" - "@babel/helper-create-class-features-plugin@^7.14.5", "@babel/helper-create-class-features-plugin@^7.15.4": version "7.15.4" resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.15.4.tgz#7f977c17bd12a5fba363cb19bea090394bf37d2e" @@ -134,7 +133,6 @@ dependencies: "@babel/types" "^7.15.4" - "@babel/helper-member-expression-to-functions@^7.15.4": version "7.15.4" resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.15.4.tgz#bfd34dc9bba9824a4658b0317ec2fd571a51e6ef" @@ -149,7 +147,6 @@ dependencies: "@babel/types" "^7.15.4" - "@babel/helper-module-transforms@^7.15.4": version "7.15.7" resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.15.7.tgz#7da80c8cbc1f02655d83f8b79d25866afe50d226" @@ -1260,10 +1257,10 @@ dependencies: merge-options "^3.0.4" -"@react-native-clipboard/clipboard@^1.8.4": - version "1.8.4" - resolved "https://registry.yarnpkg.com/@react-native-clipboard/clipboard/-/clipboard-1.8.4.tgz#4bc1fb00643688e489d8220cd635844ab5c066f9" - integrity sha512-poFq3RvXzkbXcqoQNssbZ+aNbCRzBFAWkR9QL7u9xNMgsyWZtk7d16JQoaBo8D2E+kKi+/9JOiVQzA5w+9N67w== +"@react-native-clipboard/clipboard@^1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@react-native-clipboard/clipboard/-/clipboard-1.9.0.tgz#68d6a18545b1f986098d5fb1cd710b53c322e066" + integrity sha512-O/ohFq1CAQLfoNc376Z3W6gvVcCJlje5AVk0JhsI8Q40hn+NXAWCnOM1bEePfC0uDMtp0/RCK6FotUvkQ6c4Zw== "@react-native-community/audio-toolkit@^2.0.3": version "2.0.3" @@ -1444,6 +1441,13 @@ dependencies: invariant "^2.2.4" +"@react-native-community/slider@^4.1.10": + version "4.1.10" + resolved "https://registry.yarnpkg.com/@react-native-community/slider/-/slider-4.1.10.tgz#4f004376a70530e3f067a07f2af535fdd80e72fa" + integrity sha512-+LJ/NyYyZl0jNGltFJDOeyjqCtf8ylClF8HGHCzKa8K7+MPlAPW82Fp28spBNs4EXBuq5Qi1O20iGNoMF8ZfAw== + dependencies: + flow-bin "0.113.0" + "@react-native-community/viewpager@^5.0.11": version "5.0.11" resolved "https://registry.yarnpkg.com/@react-native-community/viewpager/-/viewpager-5.0.11.tgz#dbeb2d1b2452607926407c99e4de59c7db9e3019" @@ -3564,6 +3568,11 @@ electron-to-chromium@^1.3.857: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.860.tgz#d612e54ed75fa524c12af8da3ad8121ebfe2802b" integrity sha512-gWwGZ+Wv4Mou2SJRH6JQzhTPjL5f95SX7n6VkLTQ/Q/INsZLZNQ1vH2GlZjozKyvT0kkFuCmWTwIoCj+/hUDPw== +eme-encryption-scheme-polyfill@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/eme-encryption-scheme-polyfill/-/eme-encryption-scheme-polyfill-2.0.3.tgz#2ca6e06480e06cceb5e50efd27943ac46c959878" + integrity sha512-44CNFMsqzHdKHrzWxlS7xZ8KUHn5XutBqpmCuWzNIynmAyFInHrrD3ozv/RvK9ZhgV6QY6Easx8EWAmxteNodg== + emittery@^0.7.1: version "0.7.2" resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.7.2.tgz#25595908e13af0f5674ab419396e2fb394cdfa82" @@ -4209,6 +4218,11 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== +flow-bin@0.113.0: + version "0.113.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.113.0.tgz#6457d250dbc6f71ca51e75f00a96d23cde5d987a" + integrity sha512-76uE2LGNe50wm+Jup8Np4FBcMbyy5V2iE+K25PPIYLaEMGHrL1jnQfP9L0hTzA5oh2ZJlexRLMlaPqIYIKH9nw== + flow-parser@0.*: version "0.161.0" resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.161.0.tgz#9b8d892deaca8c180ffaf332c1d1eef44902397c" @@ -5743,6 +5757,11 @@ jsqr@^1.4.0: array-includes "^3.1.3" object.assign "^4.1.2" +keymirror@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/keymirror/-/keymirror-0.1.1.tgz#918889ea13f8d0a42e7c557250eee713adc95c35" + integrity sha1-kYiJ6hP40KQufFVyUO7nE63JXDU= + kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -5913,7 +5932,7 @@ lodash.throttle@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ= -lodash@^4.17.10, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.7.0: +lodash@^4.16.4, lodash@^4.17.10, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -6042,7 +6061,7 @@ metro-cache-key@0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-cache-key/-/metro-cache-key-0.64.0.tgz#98d0a94332453c4c52b74f72c07cc62a5c264c4f" integrity sha512-O9B65G8L/fopck45ZhdRosyVZdMtUQuX5mBWEC1NRj02iWBIUPLmYMjrunqIe8vHipCMp3DtTCm/65IlBmO8jg== - + metro-cache@0.64.0: version "0.64.0" resolved "https://registry.yarnpkg.com/metro-cache/-/metro-cache-0.64.0.tgz#a769503e12521d9e9d95ce5840ffb2efdb4e8703" @@ -6530,6 +6549,7 @@ node-fetch@^2.0.0-alpha.8, node-fetch@^2.2.0, node-fetch@^2.6.0, node-fetch@^2.6 integrity sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ== dependencies: whatwg-url "^5.0.0" + node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -7136,7 +7156,7 @@ prompts@^2.0.1, prompts@^2.4.0: kleur "^3.0.3" sisteransi "^1.0.5" -prop-types@^15.5.10, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.7.x: +prop-types@^15.5.10, prop-types@^15.5.6, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.7.x: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== @@ -7281,6 +7301,11 @@ react-native-audio-recorder-player@^3.1.2: dependencies: dooboolab-welcome "^1.3.2" +react-native-audiowaveform@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/react-native-audiowaveform/-/react-native-audiowaveform-2.0.5.tgz#fb60fe92a81433d5394c770c1bebd81f0092420d" + integrity sha512-i/8RAgBGcO8EOwY8j+y56Y6tr98dU+oYWRbuujYAvcxUUYpI2knnOkVxI7d2QiOMGt2+AqesynHq031brhB1tQ== + react-native-beautiful-video-recorder@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/react-native-beautiful-video-recorder/-/react-native-beautiful-video-recorder-2.0.1.tgz#3e66176edf2ad5a1af32091fbdbf193ab5be0b0a" @@ -7539,6 +7564,13 @@ react-native-skeleton-content-nonexpo@^1.0.11: dependencies: react-native-redash "^16.0.11" +react-native-slider@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/react-native-slider/-/react-native-slider-0.11.0.tgz#b68a0bc43c8422b24cd57947cc5ac2bcdb58fadc" + integrity sha512-jV9K87eu9uWr0uJIyrSpBLnCKvVlOySC2wynq9TFCdV9oGgjt7Niq8Q1A8R8v+5GHsuBw/s8vEj1AAkkUi+u+w== + dependencies: + prop-types "^15.5.6" + react-native-svg@^12.0.3: version "12.1.1" resolved "https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-12.1.1.tgz#5f292410b8bcc07bbc52b2da7ceb22caf5bcaaee" @@ -7571,6 +7603,27 @@ react-native-vector-icons@^8.1.0: prop-types "^15.7.2" yargs "^16.1.1" +react-native-video-controls@^2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/react-native-video-controls/-/react-native-video-controls-2.8.1.tgz#30ae707d8d218fed34bba3fc027b3943c5f438d9" + integrity sha512-dBmrE3TAKaR1gYMfbukjAM6Xo8OMZyRrxPzZtnaUgWcvGo11PQwzaI/j8HPD5fLgO+rlweP2pDpEJyIBsJvJkw== + dependencies: + lodash "^4.16.4" + +react-native-video-player@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/react-native-video-player/-/react-native-video-player-0.12.0.tgz#4e4d8a27c99b906da0f2b414be88eaab449be6a2" + integrity sha512-7h288hwlvjxxBOJ1UOoUctW8auPyq22Lxltc1FIxSJAF/tYyPcnBxAtaWOxI7CGflRn51BLVlUTclXC4CB3BZA== + +react-native-video@^5.2.0-alpha1: + version "5.2.0-alpha1" + resolved "https://registry.yarnpkg.com/react-native-video/-/react-native-video-5.2.0-alpha1.tgz#990381bf2a053f8d3f20c98ff447a7d0cc61b851" + integrity sha512-UkvawdXCdInfvV/w8HMnjDnWDirSwEyOyWsY6IJbguZk9xc0chXKM010DwkdTFldY0bkWXEP2XHyEPh/AKwKcg== + dependencies: + keymirror "^0.1.1" + prop-types "^15.7.2" + shaka-player "^2.5.9" + react-native-walkthrough-tooltip@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/react-native-walkthrough-tooltip/-/react-native-walkthrough-tooltip-1.3.0.tgz#cd92227a210a885bf9f4bec02c9229286b94949d" @@ -8189,6 +8242,13 @@ sha.js@^2.4.0, sha.js@^2.4.8: inherits "^2.0.1" safe-buffer "^5.0.1" +shaka-player@^2.5.9: + version "2.5.23" + resolved "https://registry.yarnpkg.com/shaka-player/-/shaka-player-2.5.23.tgz#db92d1c6cf2314f0180a2cec11b0e2f2560336f5" + integrity sha512-3MC9k0OXJGw8AZ4n/ZNCZS2yDxx+3as5KgH6Tx4Q5TRboTBBCu6dYPI5vp1DxKeyU12MBN1Zcbs7AKzXv2EnCg== + dependencies: + eme-encryption-scheme-polyfill "^2.0.1" + shallow-clone@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-1.0.0.tgz#4480cd06e882ef68b2ad88a3ea54832e2c48b571" @@ -8896,7 +8956,7 @@ tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - + tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -9213,8 +9273,8 @@ webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - - ions@^5.0.0: + +webidl-conversions@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA== @@ -9248,7 +9308,7 @@ whatwg-url@^5.0.0: dependencies: tr46 "~0.0.3" webidl-conversions "^3.0.0" - + whatwg-url@^8.0.0, whatwg-url@^8.5.0: version "8.7.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.7.0.tgz#656a78e510ff8f3937bc0bcbe9f5c0ac35941b77"