@100mslive/roomkit-react 0.3.5-alpha.0 → 0.3.5-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useScreenShare, useWhiteboard } from '@100mslive/react-sdk';
2
+ import { selectPeerScreenSharing, useHMSStore, useWhiteboard } from '@100mslive/react-sdk';
3
3
  import { PencilDrawIcon } from '@100mslive/react-icons';
4
4
  import { Tooltip } from '../../..';
5
5
  // @ts-ignore: No implicit Any
@@ -9,9 +9,8 @@ import { ToastManager } from '../Toast/ToastManager';
9
9
 
10
10
  export const WhiteboardToggle = () => {
11
11
  const { toggle, open, isOwner } = useWhiteboard();
12
- const { screenSharingPeerId, amIScreenSharing } = useScreenShare();
13
- const remoteScreenShare = screenSharingPeerId && !amIScreenSharing;
14
- const disabled = remoteScreenShare || (open && !isOwner);
12
+ const peerSharing = useHMSStore(selectPeerScreenSharing);
13
+ const disabled = !!peerSharing || (open && !isOwner);
15
14
 
16
15
  if (!toggle) {
17
16
  return null;
@@ -21,9 +20,7 @@ export const WhiteboardToggle = () => {
21
20
  <Tooltip
22
21
  key="whiteboard"
23
22
  title={
24
- remoteScreenShare
25
- ? 'Cannot open whiteboard when viewing a shared screen'
26
- : `${open ? 'Close' : 'Open'} Whiteboard`
23
+ peerSharing ? 'Cannot open whiteboard when viewing a shared screen' : `${open ? 'Close' : 'Open'} Whiteboard`
27
24
  }
28
25
  >
29
26
  <IconButton
@@ -1,32 +1,17 @@
1
1
  import { useEffect } from 'react';
2
- import { usePrevious } from 'react-use';
3
- import { useScreenShare, useWhiteboard } from '@100mslive/react-sdk';
2
+ import { selectPeerScreenSharing, useHMSStore, useWhiteboard } from '@100mslive/react-sdk';
4
3
 
5
4
  /**
6
- * close existing screenshare or whiteboard when the other is started
5
+ * close existing whiteboard when a screen is shared
7
6
  */
8
7
  export const useCloseScreenshareWhiteboard = () => {
9
- const { amIScreenSharing, screenSharingPeerId, toggleScreenShare } = useScreenShare();
8
+ const peerSharing = useHMSStore(selectPeerScreenSharing);
10
9
  const { isOwner: isWhiteboardOwner, toggle: toggleWhiteboard } = useWhiteboard();
11
- const prevScreenSharer = usePrevious(screenSharingPeerId);
12
- const prevWhiteboardOwner = usePrevious(isWhiteboardOwner);
13
10
 
14
- // if both screenshare and whiteboard are open, close the one that was open earlier
11
+ // if both screenshare and whiteboard are open, close the whiteboard
15
12
  useEffect(() => {
16
- if (isWhiteboardOwner && screenSharingPeerId) {
17
- if (prevScreenSharer && amIScreenSharing && !prevWhiteboardOwner) {
18
- toggleScreenShare?.();
19
- } else if (prevWhiteboardOwner && !prevScreenSharer) {
20
- toggleWhiteboard?.();
21
- }
13
+ if (isWhiteboardOwner && peerSharing) {
14
+ toggleWhiteboard?.();
22
15
  }
23
- }, [
24
- isWhiteboardOwner,
25
- screenSharingPeerId,
26
- amIScreenSharing,
27
- prevScreenSharer,
28
- prevWhiteboardOwner,
29
- toggleScreenShare,
30
- toggleWhiteboard,
31
- ]);
16
+ }, [isWhiteboardOwner, toggleWhiteboard, peerSharing]);
32
17
  };