diff --git a/package-lock.json b/package-lock.json index b00e1ed..84ee2d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,7 @@ "sdp": "^3.2.0", "secure-file-transfer": "^0.0.7", "streamsaver": "^2.0.6", - "trystero": "^0.13.1", + "trystero": "^0.15.0", "typeface-public-sans": "^1.1.13", "typeface-roboto": "^1.1.13", "typescript": "^4.9.5", @@ -25716,8 +25716,9 @@ "license": "MIT" }, "node_modules/trystero": { - "version": "0.13.1", - "license": "MIT", + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/trystero/-/trystero-0.15.0.tgz", + "integrity": "sha512-BsHx1OlMQOvGbWb5OZ8hIZUyH9H2V6HjdvsnvOLBd2LruoFn20zwJrK5kqK9K2hl/VaW1ln0dMC3E4pQb75rbA==", "dependencies": { "firebase": "^9.6.5", "ipfs-core": "0.9.0", @@ -42784,7 +42785,9 @@ "version": "1.0.1" }, "trystero": { - "version": "0.13.1", + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/trystero/-/trystero-0.15.0.tgz", + "integrity": "sha512-BsHx1OlMQOvGbWb5OZ8hIZUyH9H2V6HjdvsnvOLBd2LruoFn20zwJrK5kqK9K2hl/VaW1ln0dMC3E4pQb75rbA==", "requires": { "firebase": "^9.6.5", "ipfs-core": "npm:dry-uninstall", diff --git a/package.json b/package.json index d9fbf04..5c46657 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "sdp": "^3.2.0", "secure-file-transfer": "^0.0.7", "streamsaver": "^2.0.6", - "trystero": "^0.13.1", + "trystero": "^0.15.0", "typeface-public-sans": "^1.1.13", "typeface-roboto": "^1.1.13", "typescript": "^4.9.5", diff --git a/src/components/Room/usePeerRoomAction.ts b/src/components/Room/usePeerRoomAction.ts deleted file mode 100644 index 36aab8e..0000000 --- a/src/components/Room/usePeerRoomAction.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { useState } from 'react' - -import { PeerRoom } from 'services/PeerRoom' -import { PeerActions } from 'models/network' - -export function usePeerRoomAction(peerRoom: PeerRoom, action: PeerActions) { - const [peerRoomAction] = useState(() => peerRoom.makeAction(action)) - - return peerRoomAction -} diff --git a/src/components/Room/useRoom.ts b/src/components/Room/useRoom.ts index 3e4aaa0..ebca632 100644 --- a/src/components/Room/useRoom.ts +++ b/src/components/Room/useRoom.ts @@ -30,8 +30,6 @@ import { fileTransfer } from 'services/FileTransfer' import { messageTranscriptSizeLimit } from 'config/messaging' -import { usePeerRoomAction } from './usePeerRoomAction' - interface UseRoomConfig { roomId: string userId: string @@ -156,7 +154,7 @@ export function useRoom( ) const [sendTypingStatusChange, receiveTypingStatusChange] = - usePeerRoomAction(peerRoom, PeerActions.TYPING_STATUS_CHANGE) + peerRoom.makeAction(PeerActions.TYPING_STATUS_CHANGE) const [isTyping, setIsTypingDebounced, setIsTyping] = useDebounce( false, @@ -199,17 +197,17 @@ export function useRoom( }, [isShowingMessages, setUnreadMessages]) const [sendPeerMetadata, receivePeerMetadata] = - usePeerRoomAction(peerRoom, PeerActions.PEER_METADATA) + peerRoom.makeAction(PeerActions.PEER_METADATA) - const [sendMessageTranscript, receiveMessageTranscript] = usePeerRoomAction< + const [sendMessageTranscript, receiveMessageTranscript] = peerRoom.makeAction< Array - >(peerRoom, PeerActions.MESSAGE_TRANSCRIPT) + >(PeerActions.MESSAGE_TRANSCRIPT) const [sendPeerMessage, receivePeerMessage] = - usePeerRoomAction(peerRoom, PeerActions.MESSAGE) + peerRoom.makeAction(PeerActions.MESSAGE) const [sendPeerInlineMedia, receivePeerInlineMedia] = - usePeerRoomAction(peerRoom, PeerActions.MEDIA_MESSAGE) + peerRoom.makeAction(PeerActions.MEDIA_MESSAGE) const sendMessage = async (message: string) => { if (isMessageSending) return diff --git a/src/components/Room/useRoomAudio.ts b/src/components/Room/useRoomAudio.ts index 1db7590..7bf276e 100644 --- a/src/components/Room/useRoomAudio.ts +++ b/src/components/Room/useRoomAudio.ts @@ -5,8 +5,6 @@ import { PeerActions } from 'models/network' import { AudioState, Peer } from 'models/chat' import { PeerRoom, PeerHookType, PeerStreamType } from 'services/PeerRoom' -import { usePeerRoomAction } from './usePeerRoomAction' - interface UseRoomAudioConfig { peerRoom: PeerRoom } @@ -34,8 +32,7 @@ export function useRoomAudio({ peerRoom }: UseRoomAudioConfig) { })() }, [audioStream]) - const [sendAudioChange, receiveAudioChange] = usePeerRoomAction( - peerRoom, + const [sendAudioChange, receiveAudioChange] = peerRoom.makeAction( PeerActions.AUDIO_CHANGE ) diff --git a/src/components/Room/useRoomFileShare.ts b/src/components/Room/useRoomFileShare.ts index 83270be..06cff7d 100644 --- a/src/components/Room/useRoomFileShare.ts +++ b/src/components/Room/useRoomFileShare.ts @@ -9,8 +9,6 @@ import { PeerRoom, PeerHookType } from 'services/PeerRoom' import { fileTransfer } from 'services/FileTransfer/index' -import { usePeerRoomAction } from './usePeerRoomAction' - interface UseRoomFileShareConfig { onInlineMediaUpload: (files: File[]) => void peerRoom: PeerRoom @@ -36,10 +34,7 @@ export function useRoomFileShare({ const { peerOfferedFileMetadata, setPeerOfferedFileMetadata } = roomContext const [sendFileOfferMetadata, receiveFileOfferMetadata] = - usePeerRoomAction( - peerRoom, - PeerActions.FILE_OFFER - ) + peerRoom.makeAction(PeerActions.FILE_OFFER) receiveFileOfferMetadata((fileOfferMetadata, peerId) => { if (fileOfferMetadata) { diff --git a/src/components/Room/useRoomScreenShare.ts b/src/components/Room/useRoomScreenShare.ts index 64e781e..7ae5798 100644 --- a/src/components/Room/useRoomScreenShare.ts +++ b/src/components/Room/useRoomScreenShare.ts @@ -7,8 +7,6 @@ import { PeerActions } from 'models/network' import { ScreenShareState, Peer, VideoStreamType } from 'models/chat' import { PeerRoom, PeerHookType, PeerStreamType } from 'services/PeerRoom' -import { usePeerRoomAction } from './usePeerRoomAction' - interface UseRoomScreenShareConfig { peerRoom: PeerRoom } @@ -28,7 +26,7 @@ export function useRoomScreenShare({ peerRoom }: UseRoomScreenShareConfig) { } = roomContext const [sendScreenShare, receiveScreenShare] = - usePeerRoomAction(peerRoom, PeerActions.SCREEN_SHARE) + peerRoom.makeAction(PeerActions.SCREEN_SHARE) receiveScreenShare((screenState, peerId) => { const newPeerList = peerList.map(peer => { diff --git a/src/components/Room/useRoomVideo.ts b/src/components/Room/useRoomVideo.ts index 85c6838..ed6c941 100644 --- a/src/components/Room/useRoomVideo.ts +++ b/src/components/Room/useRoomVideo.ts @@ -8,8 +8,6 @@ import { PeerRoom, PeerHookType, PeerStreamType } from 'services/PeerRoom' import { isRecord } from 'utils' -import { usePeerRoomAction } from './usePeerRoomAction' - interface UseRoomVideoConfig { peerRoom: PeerRoom } @@ -70,8 +68,7 @@ export function useRoomVideo({ peerRoom }: UseRoomVideoConfig) { })() }, [peerRoom, selfVideoStream, setSelfVideoStream]) - const [sendVideoChange, receiveVideoChange] = usePeerRoomAction( - peerRoom, + const [sendVideoChange, receiveVideoChange] = peerRoom.makeAction( PeerActions.VIDEO_CHANGE )