diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index a10e55f..fb22753 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -9,7 +9,17 @@ import hark from 'hark'; // import Spotlights from './Spotlights'; import { getSignalingUrl } from './urlFactory'; import * as requestActions from './actions/requestActions'; -import * as stateActions from './actions/stateActions'; +import * as meActions from './actions/meActions'; +import * as roomActions from './actions/roomActions'; +import * as peerActions from './actions/peerActions'; +import * as peerVolumeActions from './actions/peerVolumeActions'; +import * as settingsActions from './actions/settingsActions'; +import * as chatActions from './actions/chatActions'; +import * as fileActions from './actions/fileActions'; +import * as lobbyPeerActions from './actions/lobbyPeerActions'; +import * as consumerActions from './actions/consumerActions'; +import * as producerActions from './actions/producerActions'; +import * as notificationActions from './actions/notificationActions'; let WebTorrent; @@ -130,7 +140,7 @@ export default class RoomClient // The room ID this._roomId = roomId; - store.dispatch(stateActions.setRoomName(roomId)); + store.dispatch(roomActions.setRoomName(roomId)); // mediasoup-client Device instance. // @type {mediasoupClient.Device} @@ -200,7 +210,7 @@ export default class RoomClient if (this._recvTransport) this._recvTransport.close(); - store.dispatch(stateActions.setRoomState('closed')); + store.dispatch(roomActions.setRoomState('closed')); window.location = '/'; } @@ -224,7 +234,7 @@ export default class RoomClient { case 'a': // Activate advanced mode { - store.dispatch(stateActions.toggleAdvancedMode()); + store.dispatch(settingsActions.toggleAdvancedMode()); store.dispatch(requestActions.notify( { text : 'Toggled advanced mode.' @@ -234,7 +244,7 @@ export default class RoomClient case '1': // Set democratic view { - store.dispatch(stateActions.setDisplayMode('democratic')); + store.dispatch(roomActions.setDisplayMode('democratic')); store.dispatch(requestActions.notify( { text : 'Changed layout to democratic view.' @@ -244,7 +254,7 @@ export default class RoomClient case '2': // Set filmstrip view { - store.dispatch(stateActions.setDisplayMode('filmstrip')); + store.dispatch(roomActions.setDisplayMode('filmstrip')); store.dispatch(requestActions.notify( { text : 'Changed layout to filmstrip view.' @@ -333,11 +343,11 @@ export default class RoomClient } else { - store.dispatch(stateActions.setDisplayName(displayName)); - store.dispatch(stateActions.setPicture(picture)); + store.dispatch(settingsActions.setDisplayName(displayName)); + store.dispatch(meActions.setPicture(picture)); } - store.dispatch(stateActions.loggedIn(true)); + store.dispatch(meActions.loggedIn(true)); store.dispatch(requestActions.notify( { @@ -349,7 +359,7 @@ export default class RoomClient { logger.debug('receiveLogoutChildWindow()'); - store.dispatch(stateActions.loggedIn(false)); + store.dispatch(meActions.loggedIn(false)); store.dispatch(requestActions.notify( { @@ -440,13 +450,13 @@ export default class RoomClient displayName = 'Guest'; store.dispatch( - stateActions.setDisplayNameInProgress(true)); + meActions.setDisplayNameInProgress(true)); try { await this.sendRequest('changeDisplayName', { displayName }); - store.dispatch(stateActions.setDisplayName(displayName)); + store.dispatch(settingsActions.setDisplayName(displayName)); store.dispatch(requestActions.notify( { @@ -465,7 +475,7 @@ export default class RoomClient } store.dispatch( - stateActions.setDisplayNameInProgress(false)); + meActions.setDisplayNameInProgress(false)); } async changePicture(picture) @@ -489,7 +499,7 @@ export default class RoomClient try { store.dispatch( - stateActions.addUserMessage(chatMessage.text)); + chatActions.addUserMessage(chatMessage.text)); await this.sendRequest('chatMessage', { chatMessage }); } @@ -525,7 +535,7 @@ export default class RoomClient handleDownload(magnetUri) { store.dispatch( - stateActions.setFileActive(magnetUri)); + fileActions.setFileActive(magnetUri)); const existingTorrent = this._webTorrent.get(magnetUri); @@ -545,7 +555,7 @@ export default class RoomClient if (torrent.progress === 1) { return store.dispatch( - stateActions.setFileDone( + fileActions.setFileDone( torrent.magnetURI, torrent.files )); @@ -558,7 +568,7 @@ export default class RoomClient if (Date.now() - lastMove > 1000) { store.dispatch( - stateActions.setFileProgress( + fileActions.setFileProgress( torrent.magnetURI, torrent.progress )); @@ -570,7 +580,7 @@ export default class RoomClient torrent.on('done', () => { store.dispatch( - stateActions.setFileDone( + fileActions.setFileDone( torrent.magnetURI, torrent.files )); @@ -598,7 +608,7 @@ export default class RoomClient text : 'File successfully shared.' })); - store.dispatch(stateActions.addFile( + store.dispatch(fileActions.addFile( this._peerId, torrent.magnetURI )); @@ -644,10 +654,10 @@ export default class RoomClient } = await this.sendRequest('serverHistory'); (chatHistory.length > 0) && store.dispatch( - stateActions.addChatHistory(chatHistory)); + chatActions.addChatHistory(chatHistory)); (fileHistory.length > 0) && store.dispatch( - stateActions.addFileHistory(fileHistory)); + fileActions.addFileHistory(fileHistory)); if (lastNHistory.length > 0) { @@ -662,21 +672,21 @@ export default class RoomClient } locked ? - store.dispatch(stateActions.setRoomLocked()) : - store.dispatch(stateActions.setRoomUnLocked()); + store.dispatch(roomActions.setRoomLocked()) : + store.dispatch(roomActions.setRoomUnLocked()); (lobbyPeers.length > 0) && lobbyPeers.forEach((peer) => { store.dispatch( - stateActions.addLobbyPeer(peer.peerId)); + lobbyPeerActions.addLobbyPeer(peer.peerId)); store.dispatch( - stateActions.setLobbyPeerDisplayName(peer.displayName)); + lobbyPeerActions.setLobbyPeerDisplayName(peer.displayName)); store.dispatch( - stateActions.setLobbyPeerPicture(peer.picture)); + lobbyPeerActions.setLobbyPeerPicture(peer.picture)); }); (accessCode != null) && store.dispatch( - stateActions.setAccessCode(accessCode)); + roomActions.setAccessCode(accessCode)); } catch (error) { @@ -702,7 +712,7 @@ export default class RoomClient 'pauseProducer', { producerId: this._micProducer.id }); store.dispatch( - stateActions.setProducerPaused(this._micProducer.id)); + producerActions.setProducerPaused(this._micProducer.id)); } catch (error) { @@ -734,7 +744,7 @@ export default class RoomClient 'resumeProducer', { producerId: this._micProducer.id }); store.dispatch( - stateActions.setProducerResumed(this._micProducer.id)); + producerActions.setProducerResumed(this._micProducer.id)); } catch (error) { @@ -798,7 +808,7 @@ export default class RoomClient logger.debug('changeAudioDevice() [deviceId: %s]', deviceId); store.dispatch( - stateActions.setAudioInProgress(true)); + meActions.setAudioInProgress(true)); try { @@ -860,14 +870,14 @@ export default class RoomClient { this._micProducer.volume = volume; - store.dispatch(stateActions.setPeerVolume(this._peerId, volume)); + store.dispatch(peerVolumeActions.setPeerVolume(this._peerId, volume)); } }); store.dispatch( - stateActions.setProducerTrack(this._micProducer.id, track)); + producerActions.setProducerTrack(this._micProducer.id, track)); - store.dispatch(stateActions.setSelectedAudioDevice(deviceId)); + store.dispatch(settingsActions.setSelectedAudioDevice(deviceId)); await this._updateAudioDevices(); } @@ -877,7 +887,7 @@ export default class RoomClient } store.dispatch( - stateActions.setAudioInProgress(false)); + meActions.setAudioInProgress(false)); } async changeVideoResolution(resolution) @@ -885,7 +895,7 @@ export default class RoomClient logger.debug('changeVideoResolution() [resolution: %s]', resolution); store.dispatch( - stateActions.setWebcamInProgress(true)); + meActions.setWebcamInProgress(true)); try { @@ -914,10 +924,10 @@ export default class RoomClient await this._webcamProducer.replaceTrack({ track }); store.dispatch( - stateActions.setProducerTrack(this._webcamProducer.id, track)); + producerActions.setProducerTrack(this._webcamProducer.id, track)); - store.dispatch(stateActions.setSelectedWebcamDevice(deviceId)); - store.dispatch(stateActions.setVideoResolution(resolution)); + store.dispatch(settingsActions.setSelectedWebcamDevice(deviceId)); + store.dispatch(settingsActions.setVideoResolution(resolution)); await this._updateWebcams(); } @@ -927,7 +937,7 @@ export default class RoomClient } store.dispatch( - stateActions.setWebcamInProgress(false)); + meActions.setWebcamInProgress(false)); } async changeWebcam(deviceId) @@ -935,7 +945,7 @@ export default class RoomClient logger.debug('changeWebcam() [deviceId: %s]', deviceId); store.dispatch( - stateActions.setWebcamInProgress(true)); + meActions.setWebcamInProgress(true)); try { @@ -967,9 +977,9 @@ export default class RoomClient await this._webcamProducer.replaceTrack({ track }); store.dispatch( - stateActions.setProducerTrack(this._webcamProducer.id, track)); + producerActions.setProducerTrack(this._webcamProducer.id, track)); - store.dispatch(stateActions.setSelectedWebcamDevice(deviceId)); + store.dispatch(settingsActions.setSelectedWebcamDevice(deviceId)); await this._updateWebcams(); } @@ -979,7 +989,7 @@ export default class RoomClient } store.dispatch( - stateActions.setWebcamInProgress(false)); + meActions.setWebcamInProgress(false)); } setSelectedPeer(peerId) @@ -989,7 +999,7 @@ export default class RoomClient this._spotlights.setPeerSpotlight(peerId); store.dispatch( - stateActions.setSelectedPeer(peerId)); + roomActions.setSelectedPeer(peerId)); } async promoteLobbyPeer(peerId) @@ -997,7 +1007,7 @@ export default class RoomClient logger.debug('promoteLobbyPeer() [peerId:"%s"]', peerId); store.dispatch( - stateActions.setLobbyPeerPromotionInProgress(peerId, true)); + lobbyPeerActions.setLobbyPeerPromotionInProgress(peerId, true)); try { @@ -1009,7 +1019,7 @@ export default class RoomClient } store.dispatch( - stateActions.setLobbyPeerPromotionInProgress(peerId, false)); + lobbyPeerActions.setLobbyPeerPromotionInProgress(peerId, false)); } // type: mic/webcam/screen @@ -1024,13 +1034,13 @@ export default class RoomClient if (type === 'mic') store.dispatch( - stateActions.setPeerAudioInProgress(peerId, true)); + peerActions.setPeerAudioInProgress(peerId, true)); else if (type === 'webcam') store.dispatch( - stateActions.setPeerVideoInProgress(peerId, true)); + peerActions.setPeerVideoInProgress(peerId, true)); else if (type === 'screen') store.dispatch( - stateActions.setPeerScreenInProgress(peerId, true)); + peerActions.setPeerScreenInProgress(peerId, true)); try { @@ -1054,13 +1064,13 @@ export default class RoomClient if (type === 'mic') store.dispatch( - stateActions.setPeerAudioInProgress(peerId, false)); + peerActions.setPeerAudioInProgress(peerId, false)); else if (type === 'webcam') store.dispatch( - stateActions.setPeerVideoInProgress(peerId, false)); + peerActions.setPeerVideoInProgress(peerId, false)); else if (type === 'screen') store.dispatch( - stateActions.setPeerScreenInProgress(peerId, false)); + peerActions.setPeerScreenInProgress(peerId, false)); } async _pauseConsumer(consumer) @@ -1077,7 +1087,7 @@ export default class RoomClient consumer.pause(); store.dispatch( - stateActions.setConsumerPaused(consumer.id, 'local')); + consumerActions.setConsumerPaused(consumer.id, 'local')); } catch (error) { @@ -1099,7 +1109,7 @@ export default class RoomClient consumer.resume(); store.dispatch( - stateActions.setConsumerResumed(consumer.id, 'local')); + consumerActions.setConsumerResumed(consumer.id, 'local')); } catch (error) { @@ -1112,14 +1122,14 @@ export default class RoomClient logger.debug('sendRaiseHandState: ', state); store.dispatch( - stateActions.setMyRaiseHandStateInProgress(true)); + meActions.setMyRaiseHandStateInProgress(true)); try { await this.sendRequest('raiseHand', { raiseHandState: state }); store.dispatch( - stateActions.setMyRaiseHandState(state)); + meActions.setMyRaiseHandState(state)); } catch (error) { @@ -1132,11 +1142,11 @@ export default class RoomClient })); // We need to refresh the component for it to render changed state - store.dispatch(stateActions.setMyRaiseHandState(!state)); + store.dispatch(meActions.setMyRaiseHandState(!state)); } store.dispatch( - stateActions.setMyRaiseHandStateInProgress(false)); + meActions.setMyRaiseHandStateInProgress(false)); } async _loadDynamicImports() @@ -1215,7 +1225,7 @@ export default class RoomClient this._spotlights = new Spotlights(this._maxSpotlights, this._signalingSocket); - store.dispatch(stateActions.setRoomState('connecting')); + store.dispatch(roomActions.setRoomState('connecting')); this._signalingSocket.on('connect', () => { @@ -1244,7 +1254,7 @@ export default class RoomClient text : 'You are disconnected, attempting to reconnect.' })); - store.dispatch(stateActions.setRoomState('connecting')); + store.dispatch(roomActions.setRoomState('connecting')); }); this._signalingSocket.on('reconnect_failed', () => @@ -1268,7 +1278,7 @@ export default class RoomClient text : 'You are reconnected.' })); - store.dispatch(stateActions.setRoomState('connected')); + store.dispatch(roomActions.setRoomState('connected')); }); this._signalingSocket.on('request', async (request, cb) => @@ -1324,7 +1334,7 @@ export default class RoomClient mediasoupClient.parseScalabilityMode( consumer.rtpParameters.encodings[0].scalabilityMode); - store.dispatch(stateActions.addConsumer( + store.dispatch(consumerActions.addConsumer( { id : consumer.id, peerId : peerId, @@ -1379,7 +1389,7 @@ export default class RoomClient { consumer.volume = volume; - store.dispatch(stateActions.setPeerVolume(peerId, volume)); + store.dispatch(peerVolumeActions.setPeerVolume(peerId, volume)); } }); } @@ -1408,7 +1418,7 @@ export default class RoomClient { case 'enteredLobby': { - store.dispatch(stateActions.setInLobby(true)); + store.dispatch(roomActions.setInLobby(true)); const { displayName } = store.getState().settings; const { picture } = store.getState().me; @@ -1420,15 +1430,15 @@ export default class RoomClient case 'signInRequired': { - store.dispatch(stateActions.setSignInRequired(true)); + store.dispatch(roomActions.setSignInRequired(true)); break; } case 'roomReady': { - store.dispatch(stateActions.toggleJoined()); - store.dispatch(stateActions.setInLobby(false)); + store.dispatch(roomActions.toggleJoined()); + store.dispatch(roomActions.setInLobby(false)); await this._joinRoom({ joinVideo }); @@ -1438,7 +1448,7 @@ export default class RoomClient case 'lockRoom': { store.dispatch( - stateActions.setRoomLocked()); + roomActions.setRoomLocked()); store.dispatch(requestActions.notify( { @@ -1451,7 +1461,7 @@ export default class RoomClient case 'unlockRoom': { store.dispatch( - stateActions.setRoomUnLocked()); + roomActions.setRoomUnLocked()); store.dispatch(requestActions.notify( { @@ -1466,9 +1476,9 @@ export default class RoomClient const { peerId } = notification.data; store.dispatch( - stateActions.addLobbyPeer(peerId)); + lobbyPeerActions.addLobbyPeer(peerId)); store.dispatch( - stateActions.setToolbarsVisible(true)); + roomActions.setToolbarsVisible(true)); store.dispatch(requestActions.notify( { @@ -1483,7 +1493,7 @@ export default class RoomClient const { peerId } = notification.data; store.dispatch( - stateActions.removeLobbyPeer(peerId)); + lobbyPeerActions.removeLobbyPeer(peerId)); store.dispatch(requestActions.notify( { @@ -1496,25 +1506,25 @@ export default class RoomClient case 'lobby:promotedPeer': { const { peerId } = notification.data; - + store.dispatch( - stateActions.removeLobbyPeer(peerId)); - + lobbyPeerActions.removeLobbyPeer(peerId)); + break; } case 'lobby:changeDisplayName': { const { peerId, displayName } = notification.data; - + store.dispatch( - stateActions.setLobbyPeerDisplayName(displayName, peerId)); - + lobbyPeerActions.setLobbyPeerDisplayName(displayName, peerId)); + store.dispatch(requestActions.notify( { text : `Participant in lobby changed name to ${displayName}.` })); - + break; } @@ -1523,13 +1533,13 @@ export default class RoomClient const { peerId, picture } = notification.data; store.dispatch( - stateActions.setLobbyPeerPicture(picture, peerId)); - + lobbyPeerActions.setLobbyPeerPicture(picture, peerId)); + store.dispatch(requestActions.notify( { text : 'Participant in lobby changed picture.' })); - + break; } @@ -1538,13 +1548,13 @@ export default class RoomClient const { accessCode } = notification.data; store.dispatch( - stateActions.setAccessCode(accessCode)); - + roomActions.setAccessCode(accessCode)); + store.dispatch(requestActions.notify( { text : 'Access code for room updated' })); - + break; } @@ -1553,7 +1563,7 @@ export default class RoomClient const { joinByAccessCode } = notification.data; store.dispatch( - stateActions.setJoinByAccessCode(joinByAccessCode)); + roomActions.setJoinByAccessCode(joinByAccessCode)); if (joinByAccessCode) { @@ -1569,7 +1579,7 @@ export default class RoomClient text : 'Access code for room is now deactivated' })); } - + break; } @@ -1578,8 +1588,8 @@ export default class RoomClient const { peerId } = notification.data; store.dispatch( - stateActions.setRoomActiveSpeaker(peerId)); - + roomActions.setRoomActiveSpeaker(peerId)); + if (peerId && peerId !== this._peerId) this._spotlights.handleActiveSpeaker(peerId); @@ -1591,7 +1601,7 @@ export default class RoomClient const { peerId, displayName, oldDisplayName } = notification.data; store.dispatch( - stateActions.setPeerDisplayName(displayName, peerId)); + peerActions.setPeerDisplayName(displayName, peerId)); store.dispatch(requestActions.notify( { @@ -1605,7 +1615,7 @@ export default class RoomClient { const { peerId, picture } = notification.data; - store.dispatch(stateActions.setPeerPicture(peerId, picture)); + store.dispatch(peerActions.setPeerPicture(peerId, picture)); break; } @@ -1615,7 +1625,7 @@ export default class RoomClient const { peerId, chatMessage } = notification.data; store.dispatch( - stateActions.addResponseMessage({ ...chatMessage, peerId })); + chatActions.addResponseMessage({ ...chatMessage, peerId })); if ( !store.getState().toolarea.toolAreaOpen || @@ -1624,7 +1634,7 @@ export default class RoomClient ) // Make sound { store.dispatch( - stateActions.setToolbarsVisible(true)); + roomActions.setToolbarsVisible(true)); this._soundNotification(); } @@ -1635,7 +1645,7 @@ export default class RoomClient { const { peerId, magnetUri } = notification.data; - store.dispatch(stateActions.addFile(peerId, magnetUri)); + store.dispatch(fileActions.addFile(peerId, magnetUri)); store.dispatch(requestActions.notify( { @@ -1649,7 +1659,7 @@ export default class RoomClient ) // Make sound { store.dispatch( - stateActions.setToolbarsVisible(true)); + roomActions.setToolbarsVisible(true)); this._soundNotification(); } @@ -1661,7 +1671,7 @@ export default class RoomClient const { producerId, score } = notification.data; store.dispatch( - stateActions.setProducerScore(producerId, score)); + producerActions.setProducerScore(producerId, score)); break; } @@ -1671,7 +1681,7 @@ export default class RoomClient const { id, displayName, picture, device } = notification.data; store.dispatch( - stateActions.addPeer({ id, displayName, picture, device, consumers: [] })); + peerActions.addPeer({ id, displayName, picture, device, consumers: [] })); store.dispatch(requestActions.notify( { @@ -1686,7 +1696,7 @@ export default class RoomClient const { peerId } = notification.data; store.dispatch( - stateActions.removePeer(peerId)); + peerActions.removePeer(peerId)); break; } @@ -1709,7 +1719,7 @@ export default class RoomClient const { peerId } = consumer.appData; store.dispatch( - stateActions.removeConsumer(consumerId, peerId)); + consumerActions.removeConsumer(consumerId, peerId)); break; } @@ -1723,7 +1733,7 @@ export default class RoomClient break; store.dispatch( - stateActions.setConsumerPaused(consumerId, 'remote')); + consumerActions.setConsumerPaused(consumerId, 'remote')); break; } @@ -1737,7 +1747,7 @@ export default class RoomClient break; store.dispatch( - stateActions.setConsumerResumed(consumerId, 'remote')); + consumerActions.setConsumerResumed(consumerId, 'remote')); break; } @@ -1750,7 +1760,7 @@ export default class RoomClient if (!consumer) break; - store.dispatch(stateActions.setConsumerCurrentLayers( + store.dispatch(consumerActions.setConsumerCurrentLayers( consumerId, spatialLayer, temporalLayer)); break; @@ -1761,7 +1771,7 @@ export default class RoomClient const { consumerId, score } = notification.data; store.dispatch( - stateActions.setConsumerScore(consumerId, score)); + consumerActions.setConsumerScore(consumerId, score)); break; } @@ -1896,7 +1906,7 @@ export default class RoomClient }); // Set our media capabilities. - store.dispatch(stateActions.setMediaCapabilities( + store.dispatch(meActions.setMediaCapabilities( { canSendMic : this._mediasoupDevice.canProduce('audio'), canSendWebcam : this._mediasoupDevice.canProduce('video'), @@ -1919,14 +1929,14 @@ export default class RoomClient for (const peer of peers) { store.dispatch( - stateActions.addPeer({ ...peer, consumers: [] })); + peerActions.addPeer({ ...peer, consumers: [] })); } this._spotlights.addPeers(peers); this._spotlights.on('spotlights-updated', (spotlights) => { - store.dispatch(stateActions.setSpotlights(spotlights)); + store.dispatch(roomActions.setSpotlights(spotlights)); this.updateSpotlights(spotlights); }); @@ -1940,10 +1950,10 @@ export default class RoomClient this.enableWebcam(); } - store.dispatch(stateActions.setRoomState('connected')); + store.dispatch(roomActions.setRoomState('connected')); // Clean all the existing notifcations. - store.dispatch(stateActions.removeAllNotifications()); + store.dispatch(notificationActions.removeAllNotifications()); this.getServerHistory(); @@ -1956,7 +1966,7 @@ export default class RoomClient } catch (error) { - logger.error('_joinRoom() failed:%o', error); + logger.error('_joinRoom() failed:"%o"', error); store.dispatch(requestActions.notify( { @@ -1977,7 +1987,7 @@ export default class RoomClient await this.sendRequest('lockRoom'); store.dispatch( - stateActions.setRoomLocked()); + roomActions.setRoomLocked()); store.dispatch(requestActions.notify( { @@ -2005,7 +2015,7 @@ export default class RoomClient await this.sendRequest('unlockRoom'); store.dispatch( - stateActions.setRoomUnLocked()); + roomActions.setRoomUnLocked()); store.dispatch(requestActions.notify( { @@ -2033,7 +2043,7 @@ export default class RoomClient await this.sendRequest('setAccessCode', { accessCode: code }); store.dispatch( - stateActions.setAccessCode(code)); + roomActions.setAccessCode(code)); store.dispatch(requestActions.notify( { @@ -2060,7 +2070,7 @@ export default class RoomClient await this.sendRequest('setJoinByAccessCode', { joinByAccessCode: value }); store.dispatch( - stateActions.setJoinByAccessCode(value)); + roomActions.setJoinByAccessCode(value)); store.dispatch(requestActions.notify( { @@ -2093,7 +2103,7 @@ export default class RoomClient let track; store.dispatch( - stateActions.setAudioInProgress(true)); + meActions.setAudioInProgress(true)); try { @@ -2132,7 +2142,7 @@ export default class RoomClient { source: 'mic' } }); - store.dispatch(stateActions.addProducer( + store.dispatch(producerActions.addProducer( { id : this._micProducer.id, source : 'mic', @@ -2142,7 +2152,7 @@ export default class RoomClient codec : this._micProducer.rtpParameters.codecs[0].mimeType.split('/')[1] })); - store.dispatch(stateActions.setSelectedAudioDevice(deviceId)); + store.dispatch(settingsActions.setSelectedAudioDevice(deviceId)); await this._updateAudioDevices(); @@ -2196,7 +2206,7 @@ export default class RoomClient { this._micProducer.volume = volume; - store.dispatch(stateActions.setPeerVolume(this._peerId, volume)); + store.dispatch(peerVolumeActions.setPeerVolume(this._peerId, volume)); } }); } @@ -2216,7 +2226,7 @@ export default class RoomClient } store.dispatch( - stateActions.setAudioInProgress(false)); + meActions.setAudioInProgress(false)); } async disableMic() @@ -2226,12 +2236,12 @@ export default class RoomClient if (!this._micProducer) return; - store.dispatch(stateActions.setAudioInProgress(true)); + store.dispatch(meActions.setAudioInProgress(true)); this._micProducer.close(); store.dispatch( - stateActions.removeProducer(this._micProducer.id)); + producerActions.removeProducer(this._micProducer.id)); try { @@ -2249,7 +2259,7 @@ export default class RoomClient this._micProducer = null; - store.dispatch(stateActions.setAudioInProgress(false)); + store.dispatch(meActions.setAudioInProgress(false)); } async enableScreenSharing() @@ -2266,7 +2276,7 @@ export default class RoomClient let track; - store.dispatch(stateActions.setScreenShareInProgress(true)); + store.dispatch(meActions.setScreenShareInProgress(true)); try { @@ -2312,7 +2322,7 @@ export default class RoomClient }); } - store.dispatch(stateActions.addProducer( + store.dispatch(producerActions.addProducer( { id : this._screenSharingProducer.id, deviceLabel : 'screen', @@ -2356,7 +2366,7 @@ export default class RoomClient track.stop(); } - store.dispatch(stateActions.setScreenShareInProgress(false)); + store.dispatch(meActions.setScreenShareInProgress(false)); } async disableScreenSharing() @@ -2366,12 +2376,12 @@ export default class RoomClient if (!this._screenSharingProducer) return; - store.dispatch(stateActions.setScreenShareInProgress(true)); + store.dispatch(meActions.setScreenShareInProgress(true)); this._screenSharingProducer.close(); store.dispatch( - stateActions.removeProducer(this._screenSharingProducer.id)); + producerActions.removeProducer(this._screenSharingProducer.id)); try { @@ -2389,7 +2399,7 @@ export default class RoomClient this._screenSharingProducer = null; - store.dispatch(stateActions.setScreenShareInProgress(false)); + store.dispatch(meActions.setScreenShareInProgress(false)); } async enableWebcam() @@ -2408,7 +2418,7 @@ export default class RoomClient let track; store.dispatch( - stateActions.setWebcamInProgress(true)); + meActions.setWebcamInProgress(true)); try { @@ -2464,7 +2474,7 @@ export default class RoomClient }); } - store.dispatch(stateActions.addProducer( + store.dispatch(producerActions.addProducer( { id : this._webcamProducer.id, deviceLabel : device.label, @@ -2475,7 +2485,7 @@ export default class RoomClient codec : this._webcamProducer.rtpParameters.codecs[0].mimeType.split('/')[1] })); - store.dispatch(stateActions.setSelectedWebcamDevice(deviceId)); + store.dispatch(settingsActions.setSelectedWebcamDevice(deviceId)); await this._updateWebcams(); @@ -2513,7 +2523,7 @@ export default class RoomClient } store.dispatch( - stateActions.setWebcamInProgress(false)); + meActions.setWebcamInProgress(false)); } async disableWebcam() @@ -2523,12 +2533,12 @@ export default class RoomClient if (!this._webcamProducer) return; - store.dispatch(stateActions.setWebcamInProgress(true)); + store.dispatch(meActions.setWebcamInProgress(true)); this._webcamProducer.close(); store.dispatch( - stateActions.removeProducer(this._webcamProducer.id)); + producerActions.removeProducer(this._webcamProducer.id)); try { @@ -2546,7 +2556,7 @@ export default class RoomClient this._webcamProducer = null; - store.dispatch(stateActions.setWebcamInProgress(false)); + store.dispatch(meActions.setWebcamInProgress(false)); } async _updateAudioDevices() @@ -2571,7 +2581,7 @@ export default class RoomClient } store.dispatch( - stateActions.setAudioDevices(this._audioDevices)); + meActions.setAudioDevices(this._audioDevices)); } catch (error) { @@ -2601,7 +2611,7 @@ export default class RoomClient } store.dispatch( - stateActions.setWebcamDevices(this._webcams)); + meActions.setWebcamDevices(this._webcams)); } catch (error) { diff --git a/app/src/actions/chatActions.js b/app/src/actions/chatActions.js new file mode 100644 index 0000000..c38d92d --- /dev/null +++ b/app/src/actions/chatActions.js @@ -0,0 +1,17 @@ +export const addUserMessage = (text) => + ({ + type : 'ADD_NEW_USER_MESSAGE', + payload : { text } + }); + +export const addResponseMessage = (message) => + ({ + type : 'ADD_NEW_RESPONSE_MESSAGE', + payload : { message } + }); + +export const addChatHistory = (chatHistory) => + ({ + type : 'ADD_CHAT_HISTORY', + payload : { chatHistory } + }); \ No newline at end of file diff --git a/app/src/actions/consumerActions.js b/app/src/actions/consumerActions.js new file mode 100644 index 0000000..0c7bb65 --- /dev/null +++ b/app/src/actions/consumerActions.js @@ -0,0 +1,47 @@ +export const addConsumer = (consumer, peerId) => + ({ + type : 'ADD_CONSUMER', + payload : { consumer, peerId } + }); + +export const removeConsumer = (consumerId, peerId) => + ({ + type : 'REMOVE_CONSUMER', + payload : { consumerId, peerId } + }); + +export const setConsumerPaused = (consumerId, originator) => + ({ + type : 'SET_CONSUMER_PAUSED', + payload : { consumerId, originator } + }); + +export const setConsumerResumed = (consumerId, originator) => + ({ + type : 'SET_CONSUMER_RESUMED', + payload : { consumerId, originator } + }); + +export const setConsumerCurrentLayers = (consumerId, spatialLayer, temporalLayer) => + ({ + type : 'SET_CONSUMER_CURRENT_LAYERS', + payload : { consumerId, spatialLayer, temporalLayer } + }); + +export const setConsumerPreferredLayers = (consumerId, spatialLayer, temporalLayer) => + ({ + type : 'SET_CONSUMER_PREFERRED_LAYERS', + payload : { consumerId, spatialLayer, temporalLayer } + }); + +export const setConsumerTrack = (consumerId, track) => + ({ + type : 'SET_CONSUMER_TRACK', + payload : { consumerId, track } + }); + +export const setConsumerScore = (consumerId, score) => + ({ + type : 'SET_CONSUMER_SCORE', + payload : { consumerId, score } + }); \ No newline at end of file diff --git a/app/src/actions/fileActions.js b/app/src/actions/fileActions.js new file mode 100644 index 0000000..f9277d6 --- /dev/null +++ b/app/src/actions/fileActions.js @@ -0,0 +1,35 @@ +export const addFile = (peerId, magnetUri) => + ({ + type : 'ADD_FILE', + payload : { peerId, magnetUri } + }); + +export const addFileHistory = (fileHistory) => + ({ + type : 'ADD_FILE_HISTORY', + payload : { fileHistory } + }); + +export const setFileActive = (magnetUri) => + ({ + type : 'SET_FILE_ACTIVE', + payload : { magnetUri } + }); + +export const setFileInActive = (magnetUri) => + ({ + type : 'SET_FILE_INACTIVE', + payload : { magnetUri } + }); + +export const setFileProgress = (magnetUri, progress) => + ({ + type : 'SET_FILE_PROGRESS', + payload : { magnetUri, progress } + }); + +export const setFileDone = (magnetUri, sharedFiles) => + ({ + type : 'SET_FILE_DONE', + payload : { magnetUri, sharedFiles } + }); \ No newline at end of file diff --git a/app/src/actions/lobbyPeerActions.js b/app/src/actions/lobbyPeerActions.js new file mode 100644 index 0000000..cbbc909 --- /dev/null +++ b/app/src/actions/lobbyPeerActions.js @@ -0,0 +1,29 @@ +export const addLobbyPeer = (peerId) => + ({ + type : 'ADD_LOBBY_PEER', + payload : { peerId } + }); + +export const removeLobbyPeer = (peerId) => + ({ + type : 'REMOVE_LOBBY_PEER', + payload : { peerId } + }); + +export const setLobbyPeerDisplayName = (displayName, peerId) => + ({ + type : 'SET_LOBBY_PEER_DISPLAY_NAME', + payload : { displayName, peerId } + }); + +export const setLobbyPeerPicture = (picture, peerId) => + ({ + type : 'SET_LOBBY_PEER_PICTURE', + payload : { picture, peerId } + }); + +export const setLobbyPeerPromotionInProgress = (peerId, flag) => + ({ + type : 'SET_LOBBY_PEER_PROMOTION_IN_PROGRESS', + payload : { peerId, flag } + }); \ No newline at end of file diff --git a/app/src/actions/meActions.js b/app/src/actions/meActions.js new file mode 100644 index 0000000..d76002b --- /dev/null +++ b/app/src/actions/meActions.js @@ -0,0 +1,76 @@ +export const setMe = ({ peerId, device, loginEnabled }) => + ({ + type : 'SET_ME', + payload : { peerId, device, loginEnabled } + }); + +export const loggedIn = (flag) => + ({ + type : 'LOGGED_IN', + payload : { flag } + }); + +export const setPicture = (picture) => + ({ + type : 'SET_PICTURE', + payload : { picture } + }); + +export const setMediaCapabilities = ({ + canSendMic, + canSendWebcam, + canShareScreen, + canShareFiles + }) => + ({ + type : 'SET_MEDIA_CAPABILITIES', + payload : { canSendMic, canSendWebcam, canShareScreen, canShareFiles } + }); + +export const setAudioDevices = (devices) => + ({ + type : 'SET_AUDIO_DEVICES', + payload : { devices } + }); + +export const setWebcamDevices = (devices) => + ({ + type : 'SET_WEBCAM_DEVICES', + payload : { devices } + }); + +export const setMyRaiseHandState = (flag) => + ({ + type : 'SET_MY_RAISE_HAND_STATE', + payload : { flag } + }); + +export const setAudioInProgress = (flag) => + ({ + type : 'SET_AUDIO_IN_PROGRESS', + payload : { flag } + }); + +export const setWebcamInProgress = (flag) => + ({ + type : 'SET_WEBCAM_IN_PROGRESS', + payload : { flag } + }); + +export const setScreenShareInProgress = (flag) => + ({ + type : 'SET_SCREEN_SHARE_IN_PROGRESS', + payload : { flag } + }); + +export const setMyRaiseHandStateInProgress = (flag) => + ({ + type : 'SET_MY_RAISE_HAND_STATE_IN_PROGRESS', + payload : { flag } + }); + +export const setDisplayNameInProgress = (flag) => + ({ + type : 'SET_DISPLAY_NAME_IN_PROGRESS', + payload : { flag } + }); diff --git a/app/src/actions/notificationActions.js b/app/src/actions/notificationActions.js new file mode 100644 index 0000000..c1242d0 --- /dev/null +++ b/app/src/actions/notificationActions.js @@ -0,0 +1,16 @@ +export const addNotification = (notification) => + ({ + type : 'ADD_NOTIFICATION', + payload : { notification } + }); + +export const removeNotification = (notificationId) => + ({ + type : 'REMOVE_NOTIFICATION', + payload : { notificationId } + }); + +export const removeAllNotifications = () => + ({ + type : 'REMOVE_ALL_NOTIFICATIONS' + }); \ No newline at end of file diff --git a/app/src/actions/peerActions.js b/app/src/actions/peerActions.js new file mode 100644 index 0000000..4caca32 --- /dev/null +++ b/app/src/actions/peerActions.js @@ -0,0 +1,47 @@ +export const addPeer = (peer) => + ({ + type : 'ADD_PEER', + payload : { peer } + }); + +export const removePeer = (peerId) => + ({ + type : 'REMOVE_PEER', + payload : { peerId } + }); + +export const setPeerDisplayName = (displayName, peerId) => + ({ + type : 'SET_PEER_DISPLAY_NAME', + payload : { displayName, peerId } + }); + +export const setPeerVideoInProgress = (peerId, flag) => + ({ + type : 'SET_PEER_VIDEO_IN_PROGRESS', + payload : { peerId, flag } + }); + +export const setPeerAudioInProgress = (peerId, flag) => + ({ + type : 'SET_PEER_AUDIO_IN_PROGRESS', + payload : { peerId, flag } + }); + +export const setPeerScreenInProgress = (peerId, flag) => + ({ + type : 'SET_PEER_SCREEN_IN_PROGRESS', + payload : { peerId, flag } + }); + +export const setPeerRaiseHandState = (peerId, raiseHandState) => + ({ + type : 'SET_PEER_RAISE_HAND_STATE', + payload : { peerId, raiseHandState } + }); + +export const setPeerPicture = (peerId, picture) => + ({ + type : 'SET_PEER_PICTURE', + payload : { peerId, picture } + }); diff --git a/app/src/actions/peerVolumeActions.js b/app/src/actions/peerVolumeActions.js new file mode 100644 index 0000000..2802e82 --- /dev/null +++ b/app/src/actions/peerVolumeActions.js @@ -0,0 +1,5 @@ +export const setPeerVolume = (peerId, volume) => + ({ + type : 'SET_PEER_VOLUME', + payload : { peerId, volume } + }); diff --git a/app/src/actions/producerActions.js b/app/src/actions/producerActions.js new file mode 100644 index 0000000..a7440f4 --- /dev/null +++ b/app/src/actions/producerActions.js @@ -0,0 +1,35 @@ +export const addProducer = (producer) => + ({ + type : 'ADD_PRODUCER', + payload : { producer } + }); + +export const removeProducer = (producerId) => + ({ + type : 'REMOVE_PRODUCER', + payload : { producerId } + }); + +export const setProducerPaused = (producerId, originator) => + ({ + type : 'SET_PRODUCER_PAUSED', + payload : { producerId, originator } + }); + +export const setProducerResumed = (producerId, originator) => + ({ + type : 'SET_PRODUCER_RESUMED', + payload : { producerId, originator } + }); + +export const setProducerTrack = (producerId, track) => + ({ + type : 'SET_PRODUCER_TRACK', + payload : { producerId, track } + }); + +export const setProducerScore = (producerId, score) => + ({ + type : 'SET_PRODUCER_SCORE', + payload : { producerId, score } + }); \ No newline at end of file diff --git a/app/src/actions/requestActions.js b/app/src/actions/requestActions.js index a6b99d8..4b521c8 100644 --- a/app/src/actions/requestActions.js +++ b/app/src/actions/requestActions.js @@ -1,5 +1,5 @@ import randomString from 'random-string'; -import * as stateActions from './stateActions'; +import * as notificationActions from './notificationActions'; // This returns a redux-thunk action (a function). export const notify = ({ type = 'info', text, timeout }) => @@ -30,11 +30,11 @@ export const notify = ({ type = 'info', text, timeout }) => return (dispatch) => { - dispatch(stateActions.addNotification(notification)); + dispatch(notificationActions.addNotification(notification)); setTimeout(() => { - dispatch(stateActions.removeNotification(notification.id)); + dispatch(notificationActions.removeNotification(notification.id)); }, timeout); }; }; diff --git a/app/src/actions/roomActions.js b/app/src/actions/roomActions.js new file mode 100644 index 0000000..156f638 --- /dev/null +++ b/app/src/actions/roomActions.js @@ -0,0 +1,118 @@ +export const setRoomUrl = (url) => + ({ + type : 'SET_ROOM_URL', + payload : { url } + }); + +export const setRoomName = (name) => + ({ + type : 'SET_ROOM_NAME', + payload : { name } + + }); + +export const setRoomState = (state) => + ({ + type : 'SET_ROOM_STATE', + payload : { state } + + }); + +export const setRoomActiveSpeaker = (peerId) => + ({ + type : 'SET_ROOM_ACTIVE_SPEAKER', + payload : { peerId } + }); + +export const setRoomLocked = () => + ({ + type : 'SET_ROOM_LOCKED' + }); + +export const setRoomUnLocked = () => + ({ + type : 'SET_ROOM_UNLOCKED' + }); + +export const setInLobby = (inLobby) => + ({ + type : 'SET_IN_LOBBY', + payload : { inLobby } + }); + +export const setSignInRequired = (signInRequired) => + ({ + type : 'SET_SIGN_IN_REQUIRED', + payload : { signInRequired } + }); + +export const setAccessCode = (accessCode) => + ({ + type : 'SET_ACCESS_CODE', + payload : { accessCode } + }); + +export const setJoinByAccessCode = (joinByAccessCode) => + ({ + type : 'SET_JOIN_BY_ACCESS_CODE', + payload : { joinByAccessCode } + }); + +export const setSettingsOpen = ({ settingsOpen }) => + ({ + type : 'SET_SETTINGS_OPEN', + payload : { settingsOpen } + }); + +export const setLockDialogOpen = ({ lockDialogOpen }) => + ({ + type : 'SET_LOCK_DIALOG_OPEN', + payload : { lockDialogOpen } + }); + +export const setFileSharingSupported = (supported) => + ({ + type : 'FILE_SHARING_SUPPORTED', + payload : { supported } + }); + +export const toggleConsumerWindow = (consumerId) => + ({ + type : 'TOGGLE_WINDOW_CONSUMER', + payload : { consumerId } + }); + +export const setToolbarsVisible = (toolbarsVisible) => + ({ + type : 'SET_TOOLBARS_VISIBLE', + payload : { toolbarsVisible } + }); + +export const setDisplayMode = (mode) => + ({ + type : 'SET_DISPLAY_MODE', + payload : { mode } + }); + +export const setSelectedPeer = (selectedPeerId) => + ({ + type : 'SET_SELECTED_PEER', + payload : { selectedPeerId } + }); + +export const setSpotlights = (spotlights) => + ({ + type : 'SET_SPOTLIGHTS', + payload : { spotlights } + }); + +export const toggleJoined = () => + ({ + type : 'TOGGLE_JOINED' + }); + +export const toggleConsumerFullscreen = (consumerId) => + ({ + type : 'TOGGLE_FULLSCREEN_CONSUMER', + payload : { consumerId } + }); \ No newline at end of file diff --git a/app/src/actions/settingsActions.js b/app/src/actions/settingsActions.js new file mode 100644 index 0000000..52110c1 --- /dev/null +++ b/app/src/actions/settingsActions.js @@ -0,0 +1,28 @@ +export const setSelectedAudioDevice = (deviceId) => + ({ + type : 'CHANGE_AUDIO_DEVICE', + payload : { deviceId } + }); + +export const setSelectedWebcamDevice = (deviceId) => + ({ + type : 'CHANGE_WEBCAM', + payload : { deviceId } + }); + +export const setVideoResolution = (resolution) => + ({ + type : 'SET_VIDEO_RESOLUTION', + payload : { resolution } + }); + +export const setDisplayName = (displayName) => + ({ + type : 'SET_DISPLAY_NAME', + payload : { displayName } + }); + +export const toggleAdvancedMode = () => + ({ + type : 'TOGGLE_ADVANCED_MODE' + }); \ No newline at end of file diff --git a/app/src/actions/stateActions.js b/app/src/actions/stateActions.js deleted file mode 100644 index 89bc05a..0000000 --- a/app/src/actions/stateActions.js +++ /dev/null @@ -1,673 +0,0 @@ -export const setRoomUrl = (url) => -{ - return { - type : 'SET_ROOM_URL', - payload : { url } - }; -}; - -export const setRoomName = (name) => -{ - return { - type : 'SET_ROOM_NAME', - payload : { name } - }; -}; - -export const setRoomState = (state) => -{ - return { - type : 'SET_ROOM_STATE', - payload : { state } - }; -}; - -export const setRoomActiveSpeaker = (peerId) => -{ - return { - type : 'SET_ROOM_ACTIVE_SPEAKER', - payload : { peerId } - }; -}; - -export const setRoomLocked = () => -{ - return { - type : 'SET_ROOM_LOCKED' - }; -}; - -export const setRoomUnLocked = () => -{ - return { - type : 'SET_ROOM_UNLOCKED' - }; -}; - -export const setInLobby = (inLobby) => -{ - return { - type : 'SET_IN_LOBBY', - payload : { inLobby } - }; -}; - -export const setSignInRequired = (signInRequired) => -{ - return { - type : 'SET_SIGN_IN_REQUIRED', - payload : { signInRequired } - }; -}; - -export const setAccessCode = (accessCode) => -{ - return { - type : 'SET_ACCESS_CODE', - payload : { accessCode } - }; -}; - -export const setJoinByAccessCode = (joinByAccessCode) => -{ - return { - type : 'SET_JOIN_BY_ACCESS_CODE', - payload : { joinByAccessCode } - }; -}; - -export const setSettingsOpen = ({ settingsOpen }) => - ({ - type : 'SET_SETTINGS_OPEN', - payload : { settingsOpen } - }); - -export const setLockDialogOpen = ({ lockDialogOpen }) => - ({ - type : 'SET_LOCK_DIALOG_OPEN', - payload : { lockDialogOpen } - }); - -export const setMe = ({ peerId, device, loginEnabled }) => -{ - return { - type : 'SET_ME', - payload : { peerId, device, loginEnabled } - }; -}; - -export const setMediaCapabilities = ({ - canSendMic, - canSendWebcam, - canShareScreen, - canShareFiles -}) => -{ - return { - type : 'SET_MEDIA_CAPABILITIES', - payload : { canSendMic, canSendWebcam, canShareScreen, canShareFiles } - }; -}; - -export const setAudioDevices = (devices) => -{ - return { - type : 'SET_AUDIO_DEVICES', - payload : { devices } - }; -}; - -export const setWebcamDevices = (devices) => -{ - return { - type : 'SET_WEBCAM_DEVICES', - payload : { devices } - }; -}; - -export const setSelectedAudioDevice = (deviceId) => -{ - return { - type : 'CHANGE_AUDIO_DEVICE', - payload : { deviceId } - }; -}; - -export const setSelectedWebcamDevice = (deviceId) => -{ - return { - type : 'CHANGE_WEBCAM', - payload : { deviceId } - }; -}; - -export const setVideoResolution = (resolution) => -{ - return { - type : 'SET_VIDEO_RESOLUTION', - payload : { resolution } - }; -}; - -export const setFileSharingSupported = (supported) => -{ - return { - type : 'FILE_SHARING_SUPPORTED', - payload : { supported } - }; -}; - -export const setDisplayName = (displayName) => -{ - return { - type : 'SET_DISPLAY_NAME', - payload : { displayName } - }; -}; - -export const setDisplayNameInProgress = (flag) => -{ - return { - type : 'SET_DISPLAY_NAME_IN_PROGRESS', - payload : { flag } - }; -}; - -export const toggleAdvancedMode = () => -{ - return { - type : 'TOGGLE_ADVANCED_MODE' - }; -}; - -export const setDisplayMode = (mode) => - ({ - type : 'SET_DISPLAY_MODE', - payload : { mode } - }); - -export const setPeerVideoInProgress = (peerId, flag) => -{ - return { - type : 'SET_PEER_VIDEO_IN_PROGRESS', - payload : { peerId, flag } - }; -}; - -export const setPeerAudioInProgress = (peerId, flag) => -{ - return { - type : 'SET_PEER_AUDIO_IN_PROGRESS', - payload : { peerId, flag } - }; -}; - -export const setPeerScreenInProgress = (peerId, flag) => -{ - return { - type : 'SET_PEER_SCREEN_IN_PROGRESS', - payload : { peerId, flag } - }; -}; - -export const setMyRaiseHandState = (flag) => -{ - return { - type : 'SET_MY_RAISE_HAND_STATE', - payload : { flag } - }; -}; - -export const toggleSettings = () => -{ - return { - type : 'TOGGLE_SETTINGS' - }; -}; - -export const toggleLockDialog = () => -{ - return { - type : 'TOGGLE_LOCK_DIALOG' - }; -}; - -export const toggleToolArea = () => -{ - return { - type : 'TOGGLE_TOOL_AREA' - }; -}; - -export const openToolArea = () => -{ - return { - type : 'OPEN_TOOL_AREA' - }; -}; - -export const closeToolArea = () => -{ - return { - type : 'CLOSE_TOOL_AREA' - }; -}; - -export const setToolTab = (toolTab) => -{ - return { - type : 'SET_TOOL_TAB', - payload : { toolTab } - }; -}; - -export const setMyRaiseHandStateInProgress = (flag) => -{ - return { - type : 'SET_MY_RAISE_HAND_STATE_IN_PROGRESS', - payload : { flag } - }; -}; - -export const setPeerRaiseHandState = (peerId, raiseHandState) => -{ - return { - type : 'SET_PEER_RAISE_HAND_STATE', - payload : { peerId, raiseHandState } - }; -}; - -export const addProducer = (producer) => -{ - return { - type : 'ADD_PRODUCER', - payload : { producer } - }; -}; - -export const removeProducer = (producerId) => -{ - return { - type : 'REMOVE_PRODUCER', - payload : { producerId } - }; -}; - -export const setProducerPaused = (producerId, originator) => -{ - return { - type : 'SET_PRODUCER_PAUSED', - payload : { producerId, originator } - }; -}; - -export const setProducerResumed = (producerId, originator) => -{ - return { - type : 'SET_PRODUCER_RESUMED', - payload : { producerId, originator } - }; -}; - -export const setProducerTrack = (producerId, track) => -{ - return { - type : 'SET_PRODUCER_TRACK', - payload : { producerId, track } - }; -}; - -export const setProducerScore = (producerId, score) => -{ - return { - type : 'SET_PRODUCER_SCORE', - payload : { producerId, score } - }; -}; - -export const setAudioInProgress = (flag) => -{ - return { - type : 'SET_AUDIO_IN_PROGRESS', - payload : { flag } - }; -}; - -export const setWebcamInProgress = (flag) => -{ - return { - type : 'SET_WEBCAM_IN_PROGRESS', - payload : { flag } - }; -}; - -export const setScreenShareInProgress = (flag) => -{ - return { - type : 'SET_SCREEN_SHARE_IN_PROGRESS', - payload : { flag } - }; -}; - -export const addPeer = (peer) => -{ - return { - type : 'ADD_PEER', - payload : { peer } - }; -}; - -export const removePeer = (peerId) => -{ - return { - type : 'REMOVE_PEER', - payload : { peerId } - }; -}; - -export const setPeerDisplayName = (displayName, peerId) => -{ - return { - type : 'SET_PEER_DISPLAY_NAME', - payload : { displayName, peerId } - }; -}; - -export const addConsumer = (consumer, peerId) => -{ - return { - type : 'ADD_CONSUMER', - payload : { consumer, peerId } - }; -}; - -export const removeConsumer = (consumerId, peerId) => -{ - return { - type : 'REMOVE_CONSUMER', - payload : { consumerId, peerId } - }; -}; - -export const setConsumerPaused = (consumerId, originator) => -{ - return { - type : 'SET_CONSUMER_PAUSED', - payload : { consumerId, originator } - }; -}; - -export const setConsumerResumed = (consumerId, originator) => -{ - return { - type : 'SET_CONSUMER_RESUMED', - payload : { consumerId, originator } - }; -}; - -export const setConsumerCurrentLayers = (consumerId, spatialLayer, temporalLayer) => -{ - return { - type : 'SET_CONSUMER_CURRENT_LAYERS', - payload : { consumerId, spatialLayer, temporalLayer } - }; -}; - -export const setConsumerPreferredLayers = (consumerId, spatialLayer, temporalLayer) => -{ - return { - type : 'SET_CONSUMER_PREFERRED_LAYERS', - payload : { consumerId, spatialLayer, temporalLayer } - }; -}; - -export const setConsumerTrack = (consumerId, track) => -{ - return { - type : 'SET_CONSUMER_TRACK', - payload : { consumerId, track } - }; -}; - -export const setConsumerScore = (consumerId, score) => -{ - return { - type : 'SET_CONSUMER_SCORE', - payload : { consumerId, score } - }; -}; - -export const setPeerVolume = (peerId, volume) => -{ - return { - type : 'SET_PEER_VOLUME', - payload : { peerId, volume } - }; -}; - -export const addLobbyPeer = (peerId) => -{ - return { - type : 'ADD_LOBBY_PEER', - payload : { peerId } - }; -}; - -export const removeLobbyPeer = (peerId) => -{ - return { - type : 'REMOVE_LOBBY_PEER', - payload : { peerId } - }; -}; - -export const setLobbyPeerDisplayName = (displayName, peerId) => -{ - return { - type : 'SET_LOBBY_PEER_DISPLAY_NAME', - payload : { displayName, peerId } - }; -}; - -export const setLobbyPeerPicture = (picture, peerId) => -{ - return { - type : 'SET_LOBBY_PEER_PICTURE', - payload : { picture, peerId } - }; -}; - -export const setLobbyPeerPromotionInProgress = (peerId, flag) => -{ - return { - type : 'SET_LOBBY_PEER_PROMOTION_IN_PROGRESS', - payload : { peerId, flag } - }; -}; - -export const addNotification = (notification) => -{ - return { - type : 'ADD_NOTIFICATION', - payload : { notification } - }; -}; - -export const removeNotification = (notificationId) => -{ - return { - type : 'REMOVE_NOTIFICATION', - payload : { notificationId } - }; -}; - -export const removeAllNotifications = () => -{ - return { - type : 'REMOVE_ALL_NOTIFICATIONS' - }; -}; - -export const toggleChat = () => -{ - return { - type : 'TOGGLE_CHAT' - }; -}; - -export const toggleConsumerFullscreen = (consumerId) => -{ - return { - type : 'TOGGLE_FULLSCREEN_CONSUMER', - payload : { consumerId } - }; -}; - -export const toggleConsumerWindow = (consumerId) => -{ - return { - type : 'TOGGLE_WINDOW_CONSUMER', - payload : { consumerId } - }; -}; - -export const setToolbarsVisible = (toolbarsVisible) => ({ - type : 'SET_TOOLBARS_VISIBLE', - payload : { toolbarsVisible } -}); - -export const increaseBadge = () => -{ - return { - type : 'INCREASE_BADGE' - }; -}; - -export const toggleInputDisabled = () => -{ - return { - type : 'TOGGLE_INPUT_DISABLED' - }; -}; - -export const addUserMessage = (text) => -{ - return { - type : 'ADD_NEW_USER_MESSAGE', - payload : { text } - }; -}; - -export const addUserFile = (file) => -{ - return { - type : 'ADD_NEW_USER_FILE', - payload : { file } - }; -}; - -export const addResponseMessage = (message) => -{ - return { - type : 'ADD_NEW_RESPONSE_MESSAGE', - payload : { message } - }; -}; - -export const addChatHistory = (chatHistory) => -{ - return { - type : 'ADD_CHAT_HISTORY', - payload : { chatHistory } - }; -}; - -export const dropMessages = () => -{ - return { - type : 'DROP_MESSAGES' - }; -}; - -export const addFile = (peerId, magnetUri) => -{ - return { - type : 'ADD_FILE', - payload : { peerId, magnetUri } - }; -}; - -export const addFileHistory = (fileHistory) => -{ - return { - type : 'ADD_FILE_HISTORY', - payload : { fileHistory } - }; -}; - -export const setFileActive = (magnetUri) => -{ - return { - type : 'SET_FILE_ACTIVE', - payload : { magnetUri } - }; -}; - -export const setFileInActive = (magnetUri) => -{ - return { - type : 'SET_FILE_INACTIVE', - payload : { magnetUri } - }; -}; - -export const setFileProgress = (magnetUri, progress) => -{ - return { - type : 'SET_FILE_PROGRESS', - payload : { magnetUri, progress } - }; -}; - -export const setFileDone = (magnetUri, sharedFiles) => -{ - return { - type : 'SET_FILE_DONE', - payload : { magnetUri, sharedFiles } - }; -}; - -export const setPicture = (picture) => - ({ - type : 'SET_PICTURE', - payload : { picture } - }); - -export const setPeerPicture = (peerId, picture) => - ({ - type : 'SET_PEER_PICTURE', - payload : { peerId, picture } - }); - -export const loggedIn = (flag) => - ({ - type : 'LOGGED_IN', - payload : { flag } - }); - -export const toggleJoined = () => - ({ - type : 'TOGGLE_JOINED' - }); - -export const setSelectedPeer = (selectedPeerId) => - ({ - type : 'SET_SELECTED_PEER', - payload : { selectedPeerId } - }); - -export const setSpotlights = (spotlights) => - ({ - type : 'SET_SPOTLIGHTS', - payload : { spotlights } - }); diff --git a/app/src/actions/toolareaActions.js b/app/src/actions/toolareaActions.js new file mode 100644 index 0000000..34ad5cb --- /dev/null +++ b/app/src/actions/toolareaActions.js @@ -0,0 +1,20 @@ +export const toggleToolArea = () => + ({ + type : 'TOGGLE_TOOL_AREA' + }); + +export const openToolArea = () => + ({ + type : 'OPEN_TOOL_AREA' + }); + +export const closeToolArea = () => + ({ + type : 'CLOSE_TOOL_AREA' + }); + +export const setToolTab = (toolTab) => + ({ + type : 'SET_TOOL_TAB', + payload : { toolTab } + }); \ No newline at end of file diff --git a/app/src/components/AccessControl/LockDialog/LockDialog.js b/app/src/components/AccessControl/LockDialog/LockDialog.js index 01c6c35..a4fbcca 100644 --- a/app/src/components/AccessControl/LockDialog/LockDialog.js +++ b/app/src/components/AccessControl/LockDialog/LockDialog.js @@ -6,7 +6,7 @@ import { import * as appPropTypes from '../../appPropTypes'; import { withStyles } from '@material-ui/core/styles'; import { withRoomContext } from '../../../RoomContext'; -import * as stateActions from '../../../actions/stateActions'; +import * as roomActions from '../../../actions/roomActions'; import PropTypes from 'prop-types'; import Dialog from '@material-ui/core/Dialog'; import DialogTitle from '@material-ui/core/DialogTitle'; @@ -175,8 +175,8 @@ const mapStateToProps = (state) => }; const mapDispatchToProps = { - handleCloseLockDialog : stateActions.setLockDialogOpen, - handleAccessCode : stateActions.setAccessCode + handleCloseLockDialog : roomActions.setLockDialogOpen, + handleAccessCode : roomActions.setAccessCode }; export default withRoomContext(connect( diff --git a/app/src/components/Containers/HiddenPeers.js b/app/src/components/Containers/HiddenPeers.js index 4afb943..0dd811a 100644 --- a/app/src/components/Containers/HiddenPeers.js +++ b/app/src/components/Containers/HiddenPeers.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { withStyles } from '@material-ui/core/styles'; -import * as stateActions from '../../actions/stateActions'; +import * as toolareaActions from '../../actions/toolareaActions'; import BuddyImage from '../../images/buddy.svg'; const styles = () => @@ -115,8 +115,8 @@ const mapDispatchToProps = (dispatch) => return { openUsersTab : () => { - dispatch(stateActions.openToolArea()); - dispatch(stateActions.setToolTab('users')); + dispatch(toolareaActions.openToolArea()); + dispatch(toolareaActions.setToolTab('users')); } }; }; diff --git a/app/src/components/Containers/Peer.js b/app/src/components/Containers/Peer.js index 4abb38f..a8132e2 100644 --- a/app/src/components/Containers/Peer.js +++ b/app/src/components/Containers/Peer.js @@ -7,7 +7,7 @@ import * as appPropTypes from '../appPropTypes'; import { withRoomContext } from '../../RoomContext'; import { withStyles } from '@material-ui/core/styles'; import useMediaQuery from '@material-ui/core/useMediaQuery'; -import * as stateActions from '../../actions/stateActions'; +import * as roomActions from '../../actions/roomActions'; import VideoView from '../VideoContainers/VideoView'; import Fab from '@material-ui/core/Fab'; import MicIcon from '@material-ui/icons/Mic'; @@ -432,12 +432,12 @@ const mapDispatchToProps = (dispatch) => toggleConsumerFullscreen : (consumer) => { if (consumer) - dispatch(stateActions.toggleConsumerFullscreen(consumer.id)); + dispatch(roomActions.toggleConsumerFullscreen(consumer.id)); }, toggleConsumerWindow : (consumer) => { if (consumer) - dispatch(stateActions.toggleConsumerWindow(consumer.id)); + dispatch(roomActions.toggleConsumerWindow(consumer.id)); } }; }; diff --git a/app/src/components/JoinDialog.js b/app/src/components/JoinDialog.js index b0f10c4..759bd89 100644 --- a/app/src/components/JoinDialog.js +++ b/app/src/components/JoinDialog.js @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; import { connect } from 'react-redux'; import { withStyles } from '@material-ui/core/styles'; import { withRoomContext } from '../RoomContext'; -import * as stateActions from '../actions/stateActions'; +import * as settingsActions from '../actions/settingsActions'; import PropTypes from 'prop-types'; import Dialog from '@material-ui/core/Dialog'; import DialogContentText from '@material-ui/core/DialogContentText'; @@ -329,7 +329,7 @@ const mapDispatchToProps = (dispatch) => return { changeDisplayName : (displayName) => { - dispatch(stateActions.setDisplayName(displayName)); + dispatch(settingsActions.setDisplayName(displayName)); } }; }; diff --git a/app/src/components/MeetingDrawer/Chat/MessageList.js b/app/src/components/MeetingDrawer/Chat/MessageList.js index a5bc154..0664f04 100644 --- a/app/src/components/MeetingDrawer/Chat/MessageList.js +++ b/app/src/components/MeetingDrawer/Chat/MessageList.js @@ -33,7 +33,7 @@ class MessageList extends React.Component shouldComponentUpdate(nextProps) { - if (nextProps.chatmessages.length !== this.props.chatmessages.length) + if (nextProps.chat.length !== this.props.chat.length) return true; return false; @@ -55,7 +55,7 @@ class MessageList extends React.Component render() { const { - chatmessages, + chat, myPicture, classes } = this.props; @@ -63,7 +63,7 @@ class MessageList extends React.Component return (
{ this.node = node; }}> { - chatmessages.map((message, index) => + chat.map((message, index) => { const messageTime = new Date(message.time); @@ -89,15 +89,15 @@ class MessageList extends React.Component MessageList.propTypes = { - chatmessages : PropTypes.array, + chat : PropTypes.array, myPicture : PropTypes.string, classes : PropTypes.object.isRequired }; const mapStateToProps = (state) => ({ - chatmessages : state.chatmessages, - myPicture : state.me.picture + chat : state.chat, + myPicture : state.me.picture }); export default connect( @@ -108,7 +108,7 @@ export default connect( areStatesEqual : (next, prev) => { return ( - prev.chatmessages === next.chatmessages && + prev.chat === next.chat && prev.me.picture === next.me.picture ); } diff --git a/app/src/components/MeetingDrawer/MeetingDrawer.js b/app/src/components/MeetingDrawer/MeetingDrawer.js index e46afa1..03bc893 100644 --- a/app/src/components/MeetingDrawer/MeetingDrawer.js +++ b/app/src/components/MeetingDrawer/MeetingDrawer.js @@ -2,7 +2,7 @@ import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; -import * as stateActions from '../../actions/stateActions'; +import * as toolareaActions from '../../actions/toolareaActions'; import AppBar from '@material-ui/core/AppBar'; import Tabs from '@material-ui/core/Tabs'; import Tab from '@material-ui/core/Tab'; @@ -114,7 +114,7 @@ const mapStateToProps = (state) => ({ }); const mapDispatchToProps = { - setToolTab : stateActions.setToolTab + setToolTab : toolareaActions.setToolTab }; export default connect( diff --git a/app/src/components/Notifications/Notifications.js b/app/src/components/Notifications/Notifications.js index 60553f9..ce2fcee 100644 --- a/app/src/components/Notifications/Notifications.js +++ b/app/src/components/Notifications/Notifications.js @@ -2,7 +2,7 @@ import { Component } from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import { withSnackbar } from 'notistack'; -import * as stateActions from '../../actions/stateActions'; +import * as notificationActions from '../../actions/notificationActions'; class Notifications extends Component { @@ -77,7 +77,7 @@ const mapStateToProps = (state) => const mapDispatchToProps = (dispatch) => ({ removeNotification : (notificationId) => - dispatch(stateActions.removeNotification({ notificationId })) + dispatch(notificationActions.removeNotification({ notificationId })) }); export default withSnackbar( diff --git a/app/src/components/Room.js b/app/src/components/Room.js index 6ae0152..f7eb661 100644 --- a/app/src/components/Room.js +++ b/app/src/components/Room.js @@ -7,7 +7,8 @@ import { import * as appPropTypes from './appPropTypes'; import { withRoomContext } from '../RoomContext'; import { withStyles } from '@material-ui/core/styles'; -import * as stateActions from '../actions/stateActions'; +import * as roomActions from '../actions/roomActions'; +import * as toolareaActions from '../actions/toolareaActions'; import { idle } from '../utils'; import FullScreen from './FullScreen'; import CookieConsent from 'react-cookie-consent'; @@ -488,19 +489,19 @@ const mapDispatchToProps = (dispatch) => ({ setToolbarsVisible : (visible) => { - dispatch(stateActions.setToolbarsVisible(visible)); + dispatch(roomActions.setToolbarsVisible(visible)); }, setSettingsOpen : (settingsOpen) => { - dispatch(stateActions.setSettingsOpen({ settingsOpen })); + dispatch(roomActions.setSettingsOpen({ settingsOpen })); }, setLockDialogOpen : (lockDialogOpen) => { - dispatch(stateActions.setLockDialogOpen({ lockDialogOpen })); + dispatch(roomActions.setLockDialogOpen({ lockDialogOpen })); }, toggleToolArea : () => { - dispatch(stateActions.toggleToolArea()); + dispatch(toolareaActions.toggleToolArea()); } }); diff --git a/app/src/components/Settings/Settings.js b/app/src/components/Settings/Settings.js index 11411da..61de221 100644 --- a/app/src/components/Settings/Settings.js +++ b/app/src/components/Settings/Settings.js @@ -3,7 +3,8 @@ import { connect } from 'react-redux'; import * as appPropTypes from '../appPropTypes'; import { withStyles } from '@material-ui/core/styles'; import { withRoomContext } from '../../RoomContext'; -import * as stateActions from '../../actions/stateActions'; +import * as roomActions from '../../actions/roomActions'; +import * as settingsActions from '../../actions/settingsActions'; import PropTypes from 'prop-types'; import Dialog from '@material-ui/core/Dialog'; import DialogTitle from '@material-ui/core/DialogTitle'; @@ -267,9 +268,9 @@ const mapStateToProps = (state) => }; const mapDispatchToProps = { - onToggleAdvancedMode : stateActions.toggleAdvancedMode, - handleChangeMode : stateActions.setDisplayMode, - handleCloseSettings : stateActions.setSettingsOpen, + onToggleAdvancedMode : settingsActions.toggleAdvancedMode, + handleChangeMode : roomActions.setDisplayMode, + handleCloseSettings : roomActions.setSettingsOpen }; export default withRoomContext(connect( diff --git a/app/src/components/VideoContainers/FullScreenView.js b/app/src/components/VideoContainers/FullScreenView.js index 6f99122..c7854ef 100644 --- a/app/src/components/VideoContainers/FullScreenView.js +++ b/app/src/components/VideoContainers/FullScreenView.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import classnames from 'classnames'; import { withStyles } from '@material-ui/core/styles'; import * as appPropTypes from '../appPropTypes'; -import * as stateActions from '../../actions/stateActions'; +import * as roomActions from '../../actions/roomActions'; import FullScreenExitIcon from '@material-ui/icons/FullscreenExit'; import VideoView from './VideoView'; @@ -148,7 +148,7 @@ const mapDispatchToProps = (dispatch) => toggleConsumerFullscreen : (consumer) => { if (consumer) - dispatch(stateActions.toggleConsumerFullscreen(consumer.id)); + dispatch(roomActions.toggleConsumerFullscreen(consumer.id)); } }); diff --git a/app/src/components/VideoWindow/VideoWindow.js b/app/src/components/VideoWindow/VideoWindow.js index 7d19905..e478070 100644 --- a/app/src/components/VideoWindow/VideoWindow.js +++ b/app/src/components/VideoWindow/VideoWindow.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import NewWindow from './NewWindow'; import PropTypes from 'prop-types'; import * as appPropTypes from '../appPropTypes'; -import * as stateActions from '../../actions/stateActions'; +import * as roomActions from '../../actions/roomActions'; import FullView from '../VideoContainers/FullView'; const VideoWindow = (props) => @@ -59,7 +59,7 @@ const mapDispatchToProps = (dispatch) => return { toggleConsumerWindow : () => { - dispatch(stateActions.toggleConsumerWindow()); + dispatch(roomActions.toggleConsumerWindow()); } }; }; diff --git a/app/src/index.js b/app/src/index.js index a412bb6..713a8fb 100644 --- a/app/src/index.js +++ b/app/src/index.js @@ -8,7 +8,8 @@ import debug from 'debug'; import RoomClient from './RoomClient'; import RoomContext from './RoomContext'; import deviceInfo from './deviceInfo'; -import * as stateActions from './actions/stateActions'; +import * as roomActions from './actions/roomActions'; +import * as meActions from './actions/meActions'; import App from './components/App'; import LoadingView from './components/LoadingView'; import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles'; @@ -73,10 +74,10 @@ function run() const device = deviceInfo(); store.dispatch( - stateActions.setRoomUrl(roomUrl)); + roomActions.setRoomUrl(roomUrl)); store.dispatch( - stateActions.setMe({ + meActions.setMe({ peerId, device, loginEnabled : window.config.loginEnabled diff --git a/app/src/reducers/chatmessages.js b/app/src/reducers/chat.js similarity index 81% rename from app/src/reducers/chatmessages.js rename to app/src/reducers/chat.js index e9ed22f..e273ee7 100644 --- a/app/src/reducers/chatmessages.js +++ b/app/src/reducers/chat.js @@ -3,7 +3,7 @@ import createNewMessage } from './helper'; -const chatmessages = (state = [], action) => +const chat = (state = [], action) => { switch (action.type) { @@ -30,14 +30,9 @@ const chatmessages = (state = [], action) => return [ ...state, ...chatHistory ]; } - case 'DROP_MESSAGES': - { - return []; - } - default: return state; } }; -export default chatmessages; +export default chat; diff --git a/app/src/reducers/files.js b/app/src/reducers/files.js index 1154b09..2475cff 100644 --- a/app/src/reducers/files.js +++ b/app/src/reducers/files.js @@ -85,13 +85,6 @@ const files = (state = {}, action) => return { ...state, [magnetUri]: newFile }; } - case 'REMOVE_FILE': - { - const { magnetUri } = action.payload; - - return state.filter((file) => file.magnetUri !== magnetUri); - } - default: return state; } diff --git a/app/src/reducers/room.js b/app/src/reducers/room.js index 0d650d3..6555605 100644 --- a/app/src/reducers/room.js +++ b/app/src/reducers/room.js @@ -116,13 +116,6 @@ const room = (state = initialState, action) => return { ...state, torrentSupport: supported }; } - case 'TOGGLE_SETTINGS': - { - const showSettings = !state.showSettings; - - return { ...state, showSettings }; - } - case 'TOGGLE_JOINED': { const joined = !state.joined; diff --git a/app/src/reducers/rootReducer.js b/app/src/reducers/rootReducer.js index 539c8d7..d4025e7 100644 --- a/app/src/reducers/rootReducer.js +++ b/app/src/reducers/rootReducer.js @@ -7,7 +7,7 @@ import lobbyPeers from './lobbyPeers'; import consumers from './consumers'; import peerVolumes from './peerVolumes'; import notifications from './notifications'; -import chatmessages from './chatmessages'; +import chat from './chat'; import toolarea from './toolarea'; import files from './files'; import settings from './settings'; @@ -21,7 +21,7 @@ export default combineReducers({ consumers, peerVolumes, notifications, - chatmessages, + chat, toolarea, files, settings