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

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  theme,
63
63
  useBorderAudioLevel,
64
64
  useTheme
65
- } from "./chunk-MXPCXPZQ.js";
65
+ } from "./chunk-ZE5KXBZW.js";
66
66
  export {
67
67
  Accordion,
68
68
  AudioLevel,
@@ -2241,7 +2241,7 @@
2241
2241
  "format": "esm"
2242
2242
  },
2243
2243
  "src/Prebuilt/components/AppData/AppData.tsx": {
2244
- "bytes": 5853,
2244
+ "bytes": 6063,
2245
2245
  "imports": [
2246
2246
  {
2247
2247
  "path": "react",
@@ -4696,7 +4696,7 @@
4696
4696
  "format": "cjs"
4697
4697
  },
4698
4698
  "../hms-video-store/dist/index.js": {
4699
- "bytes": 329654,
4699
+ "bytes": 330097,
4700
4700
  "imports": [
4701
4701
  {
4702
4702
  "path": "../../node_modules/reselect/es/index.js",
@@ -6301,7 +6301,7 @@
6301
6301
  "format": "esm"
6302
6302
  },
6303
6303
  "src/Prebuilt/components/Footer/WhiteboardToggle.tsx": {
6304
- "bytes": 1360,
6304
+ "bytes": 1272,
6305
6305
  "imports": [
6306
6306
  {
6307
6307
  "path": "react",
@@ -10890,18 +10890,13 @@
10890
10890
  "format": "esm"
10891
10891
  },
10892
10892
  "src/Prebuilt/components/hooks/useCloseScreenshareWhiteboard.tsx": {
10893
- "bytes": 1121,
10893
+ "bytes": 617,
10894
10894
  "imports": [
10895
10895
  {
10896
10896
  "path": "react",
10897
10897
  "kind": "import-statement",
10898
10898
  "external": true
10899
10899
  },
10900
- {
10901
- "path": "react-use",
10902
- "kind": "import-statement",
10903
- "external": true
10904
- },
10905
10900
  {
10906
10901
  "path": "@100mslive/react-sdk",
10907
10902
  "kind": "import-statement",
@@ -13329,7 +13324,7 @@
13329
13324
  "format": "esm"
13330
13325
  },
13331
13326
  "src/Prebuilt/App.tsx": {
13332
- "bytes": 10658,
13327
+ "bytes": 10657,
13333
13328
  "imports": [
13334
13329
  {
13335
13330
  "path": "react",
@@ -13785,7 +13780,7 @@
13785
13780
  "imports": [],
13786
13781
  "exports": [],
13787
13782
  "inputs": {},
13788
- "bytes": 3299924
13783
+ "bytes": 3300552
13789
13784
  },
13790
13785
  "dist/index.cjs.js": {
13791
13786
  "imports": [
@@ -16124,11 +16119,6 @@
16124
16119
  "kind": "require-call",
16125
16120
  "external": true
16126
16121
  },
16127
- {
16128
- "path": "react-use",
16129
- "kind": "require-call",
16130
- "external": true
16131
- },
16132
16122
  {
16133
16123
  "path": "@100mslive/react-sdk",
16134
16124
  "kind": "require-call",
@@ -16739,7 +16729,7 @@
16739
16729
  "entryPoint": "src/index.ts",
16740
16730
  "inputs": {
16741
16731
  "<define:process.env>": {
16742
- "bytesInOutput": 18248
16732
+ "bytesInOutput": 18229
16743
16733
  },
16744
16734
  "src/Theme/base.config.ts": {
16745
16735
  "bytesInOutput": 6104
@@ -17015,7 +17005,7 @@
17015
17005
  "bytesInOutput": 3450
17016
17006
  },
17017
17007
  "../../node_modules/lodash/lodash.js": {
17018
- "bytesInOutput": 224307
17008
+ "bytesInOutput": 224317
17019
17009
  },
17020
17010
  "src/Prebuilt/provider/roomLayoutProvider/constants/index.ts": {
17021
17011
  "bytesInOutput": 1887
@@ -17036,7 +17026,7 @@
17036
17026
  "bytesInOutput": 3258
17037
17027
  },
17038
17028
  "src/Prebuilt/components/AppData/AppData.tsx": {
17039
- "bytesInOutput": 6542
17029
+ "bytesInOutput": 6751
17040
17030
  },
17041
17031
  "src/Prebuilt/AppContext.tsx": {
17042
17032
  "bytesInOutput": 840
@@ -17183,13 +17173,13 @@
17183
17173
  "bytesInOutput": 6467
17184
17174
  },
17185
17175
  "../../node_modules/webrtc-adapter/src/js/chrome/getusermedia.js": {
17186
- "bytesInOutput": 6260
17176
+ "bytesInOutput": 6253
17187
17177
  },
17188
17178
  "../../node_modules/webrtc-adapter/src/js/chrome/getdisplaymedia.js": {
17189
17179
  "bytesInOutput": 1396
17190
17180
  },
17191
17181
  "../../node_modules/webrtc-adapter/src/js/chrome/chrome_shim.js": {
17192
- "bytesInOutput": 22882
17182
+ "bytesInOutput": 22897
17193
17183
  },
17194
17184
  "../../node_modules/webrtc-adapter/src/js/firefox/getusermedia.js": {
17195
17185
  "bytesInOutput": 2277
@@ -17201,13 +17191,13 @@
17201
17191
  "bytesInOutput": 9352
17202
17192
  },
17203
17193
  "../../node_modules/webrtc-adapter/src/js/safari/safari_shim.js": {
17204
- "bytesInOutput": 12019
17194
+ "bytesInOutput": 12026
17205
17195
  },
17206
17196
  "../../node_modules/sdp/sdp.js": {
17207
17197
  "bytesInOutput": 22295
17208
17198
  },
17209
17199
  "../../node_modules/webrtc-adapter/src/js/common_shim.js": {
17210
- "bytesInOutput": 12625
17200
+ "bytesInOutput": 12630
17211
17201
  },
17212
17202
  "../../node_modules/webrtc-adapter/src/js/adapter_factory.js": {
17213
17203
  "bytesInOutput": 4575
@@ -17228,7 +17218,7 @@
17228
17218
  "bytesInOutput": 615
17229
17219
  },
17230
17220
  "../hms-video-store/dist/index.js": {
17231
- "bytesInOutput": 53502
17221
+ "bytesInOutput": 53501
17232
17222
  },
17233
17223
  "src/Prebuilt/components/hooks/usePlaylistMusic.js": {
17234
17224
  "bytesInOutput": 1384
@@ -17330,7 +17320,7 @@
17330
17320
  "bytesInOutput": 1521
17331
17321
  },
17332
17322
  "src/Prebuilt/components/Footer/WhiteboardToggle.tsx": {
17333
- "bytesInOutput": 1804
17323
+ "bytesInOutput": 1729
17334
17324
  },
17335
17325
  "src/Prebuilt/components/Footer/Footer.tsx": {
17336
17326
  "bytesInOutput": 4294
@@ -17600,7 +17590,7 @@
17600
17590
  "bytesInOutput": 1943
17601
17591
  },
17602
17592
  "src/Prebuilt/components/hooks/useCloseScreenshareWhiteboard.tsx": {
17603
- "bytesInOutput": 1488
17593
+ "bytesInOutput": 849
17604
17594
  },
17605
17595
  "src/Prebuilt/components/HlsStatsOverlay.jsx": {
17606
17596
  "bytesInOutput": 4195
@@ -17744,7 +17734,7 @@
17744
17734
  "bytesInOutput": 2248
17745
17735
  },
17746
17736
  "src/Prebuilt/components/Notifications/Notifications.tsx": {
17747
- "bytesInOutput": 8889
17737
+ "bytesInOutput": 8886
17748
17738
  },
17749
17739
  "src/Prebuilt/components/Notifications/index.tsx": {
17750
17740
  "bytesInOutput": 173
@@ -17792,7 +17782,7 @@
17792
17782
  "bytesInOutput": 2980
17793
17783
  }
17794
17784
  },
17795
- "bytes": 1571138
17785
+ "bytes": 1570641
17796
17786
  }
17797
17787
  }
17798
17788
  }
@@ -2241,7 +2241,7 @@
2241
2241
  "format": "esm"
2242
2242
  },
2243
2243
  "src/Prebuilt/components/AppData/AppData.tsx": {
2244
- "bytes": 5853,
2244
+ "bytes": 6063,
2245
2245
  "imports": [
2246
2246
  {
2247
2247
  "path": "react",
@@ -4696,7 +4696,7 @@
4696
4696
  "format": "cjs"
4697
4697
  },
4698
4698
  "../hms-video-store/dist/index.js": {
4699
- "bytes": 329654,
4699
+ "bytes": 330097,
4700
4700
  "imports": [
4701
4701
  {
4702
4702
  "path": "../../node_modules/reselect/es/index.js",
@@ -6301,7 +6301,7 @@
6301
6301
  "format": "esm"
6302
6302
  },
6303
6303
  "src/Prebuilt/components/Footer/WhiteboardToggle.tsx": {
6304
- "bytes": 1360,
6304
+ "bytes": 1272,
6305
6305
  "imports": [
6306
6306
  {
6307
6307
  "path": "react",
@@ -10890,18 +10890,13 @@
10890
10890
  "format": "esm"
10891
10891
  },
10892
10892
  "src/Prebuilt/components/hooks/useCloseScreenshareWhiteboard.tsx": {
10893
- "bytes": 1121,
10893
+ "bytes": 617,
10894
10894
  "imports": [
10895
10895
  {
10896
10896
  "path": "react",
10897
10897
  "kind": "import-statement",
10898
10898
  "external": true
10899
10899
  },
10900
- {
10901
- "path": "react-use",
10902
- "kind": "import-statement",
10903
- "external": true
10904
- },
10905
10900
  {
10906
10901
  "path": "@100mslive/react-sdk",
10907
10902
  "kind": "import-statement",
@@ -13329,7 +13324,7 @@
13329
13324
  "format": "esm"
13330
13325
  },
13331
13326
  "src/Prebuilt/App.tsx": {
13332
- "bytes": 10658,
13327
+ "bytes": 10657,
13333
13328
  "imports": [
13334
13329
  {
13335
13330
  "path": "react",
@@ -13790,7 +13785,7 @@
13790
13785
  "dist/index.js": {
13791
13786
  "imports": [
13792
13787
  {
13793
- "path": "dist/chunk-MXPCXPZQ.js",
13788
+ "path": "dist/chunk-ZE5KXBZW.js",
13794
13789
  "kind": "import-statement"
13795
13790
  }
13796
13791
  ],
@@ -13863,16 +13858,16 @@
13863
13858
  "inputs": {},
13864
13859
  "bytes": 1822
13865
13860
  },
13866
- "dist/HLSView-YAR57OPP.js.map": {
13861
+ "dist/HLSView-I6DCFRWE.js.map": {
13867
13862
  "imports": [],
13868
13863
  "exports": [],
13869
13864
  "inputs": {},
13870
13865
  "bytes": 99469
13871
13866
  },
13872
- "dist/HLSView-YAR57OPP.js": {
13867
+ "dist/HLSView-I6DCFRWE.js": {
13873
13868
  "imports": [
13874
13869
  {
13875
- "path": "dist/chunk-MXPCXPZQ.js",
13870
+ "path": "dist/chunk-ZE5KXBZW.js",
13876
13871
  "kind": "import-statement"
13877
13872
  },
13878
13873
  {
@@ -14108,13 +14103,13 @@
14108
14103
  },
14109
14104
  "bytes": 61339
14110
14105
  },
14111
- "dist/chunk-MXPCXPZQ.js.map": {
14106
+ "dist/chunk-ZE5KXBZW.js.map": {
14112
14107
  "imports": [],
14113
14108
  "exports": [],
14114
14109
  "inputs": {},
14115
- "bytes": 3195905
14110
+ "bytes": 3196714
14116
14111
  },
14117
- "dist/chunk-MXPCXPZQ.js": {
14112
+ "dist/chunk-ZE5KXBZW.js": {
14118
14113
  "imports": [
14119
14114
  {
14120
14115
  "path": "react",
@@ -16496,18 +16491,13 @@
16496
16491
  "kind": "import-statement",
16497
16492
  "external": true
16498
16493
  },
16499
- {
16500
- "path": "react-use",
16501
- "kind": "import-statement",
16502
- "external": true
16503
- },
16504
16494
  {
16505
16495
  "path": "@100mslive/react-sdk",
16506
16496
  "kind": "import-statement",
16507
16497
  "external": true
16508
16498
  },
16509
16499
  {
16510
- "path": "dist/HLSView-YAR57OPP.js",
16500
+ "path": "dist/HLSView-I6DCFRWE.js",
16511
16501
  "kind": "dynamic-import"
16512
16502
  },
16513
16503
  {
@@ -16988,10 +16978,10 @@
16988
16978
  ],
16989
16979
  "inputs": {
16990
16980
  "<define:process.env>": {
16991
- "bytesInOutput": 18248
16981
+ "bytesInOutput": 18229
16992
16982
  },
16993
16983
  "../../node_modules/lodash/lodash.js": {
16994
- "bytesInOutput": 224300
16984
+ "bytesInOutput": 224310
16995
16985
  },
16996
16986
  "../../node_modules/ua-parser-js/src/ua-parser.js": {
16997
16987
  "bytesInOutput": 42491
@@ -17243,7 +17233,7 @@
17243
17233
  "bytesInOutput": 7828
17244
17234
  },
17245
17235
  "src/Prebuilt/components/AppData/AppData.tsx": {
17246
- "bytesInOutput": 5383
17236
+ "bytesInOutput": 5582
17247
17237
  },
17248
17238
  "src/Prebuilt/components/Settings/LayoutSettings.tsx": {
17249
17239
  "bytesInOutput": 2705
@@ -17384,7 +17374,7 @@
17384
17374
  "bytesInOutput": 2509
17385
17375
  },
17386
17376
  "src/Prebuilt/components/RoleChangeModal.jsx": {
17387
- "bytesInOutput": 6096
17377
+ "bytesInOutput": 6098
17388
17378
  },
17389
17379
  "src/Prebuilt/components/Settings/StartRecording.jsx": {
17390
17380
  "bytesInOutput": 4547
@@ -17426,7 +17416,7 @@
17426
17416
  "bytesInOutput": 10031
17427
17417
  },
17428
17418
  "../hms-video-store/dist/index.js": {
17429
- "bytesInOutput": 48907
17419
+ "bytesInOutput": 48906
17430
17420
  },
17431
17421
  "../../node_modules/reselect/es/index.js": {
17432
17422
  "bytesInOutput": 2537
@@ -17441,10 +17431,10 @@
17441
17431
  "bytesInOutput": 6313
17442
17432
  },
17443
17433
  "../../node_modules/webrtc-adapter/src/js/chrome/chrome_shim.js": {
17444
- "bytesInOutput": 22678
17434
+ "bytesInOutput": 22693
17445
17435
  },
17446
17436
  "../../node_modules/webrtc-adapter/src/js/chrome/getusermedia.js": {
17447
- "bytesInOutput": 6094
17437
+ "bytesInOutput": 6087
17448
17438
  },
17449
17439
  "../../node_modules/webrtc-adapter/src/js/chrome/getdisplaymedia.js": {
17450
17440
  "bytesInOutput": 1256
@@ -17459,10 +17449,10 @@
17459
17449
  "bytesInOutput": 842
17460
17450
  },
17461
17451
  "../../node_modules/webrtc-adapter/src/js/safari/safari_shim.js": {
17462
- "bytesInOutput": 11868
17452
+ "bytesInOutput": 11875
17463
17453
  },
17464
17454
  "../../node_modules/webrtc-adapter/src/js/common_shim.js": {
17465
- "bytesInOutput": 12465
17455
+ "bytesInOutput": 12470
17466
17456
  },
17467
17457
  "src/Prebuilt/components/Header/AdditionalRoomState.jsx": {
17468
17458
  "bytesInOutput": 6823
@@ -17555,7 +17545,7 @@
17555
17545
  "bytesInOutput": 1073
17556
17546
  },
17557
17547
  "src/Prebuilt/components/Footer/WhiteboardToggle.tsx": {
17558
- "bytesInOutput": 1291
17548
+ "bytesInOutput": 1222
17559
17549
  },
17560
17550
  "src/Prebuilt/components/Notifications/HLSFailureModal.tsx": {
17561
17551
  "bytesInOutput": 2414
@@ -17660,7 +17650,7 @@
17660
17650
  "bytesInOutput": 4926
17661
17651
  },
17662
17652
  "src/Prebuilt/components/Chat/ChatBody.tsx": {
17663
- "bytesInOutput": 14726
17653
+ "bytesInOutput": 14728
17664
17654
  },
17665
17655
  "src/Prebuilt/components/Chat/ChatActions.tsx": {
17666
17656
  "bytesInOutput": 9785
@@ -17765,7 +17755,7 @@
17765
17755
  "bytesInOutput": 3506
17766
17756
  },
17767
17757
  "src/Prebuilt/components/VideoLayouts/GridLayout.tsx": {
17768
- "bytesInOutput": 4521
17758
+ "bytesInOutput": 4550
17769
17759
  },
17770
17760
  "src/Prebuilt/components/VideoLayouts/EqualProminence.tsx": {
17771
17761
  "bytesInOutput": 2019
@@ -17825,7 +17815,7 @@
17825
17815
  "bytesInOutput": 1415
17826
17816
  },
17827
17817
  "src/Prebuilt/components/hooks/useCloseScreenshareWhiteboard.tsx": {
17828
- "bytesInOutput": 1097
17818
+ "bytesInOutput": 619
17829
17819
  },
17830
17820
  "src/Prebuilt/components/Header/index.tsx": {
17831
17821
  "bytesInOutput": 27
@@ -17870,7 +17860,7 @@
17870
17860
  "bytesInOutput": 27
17871
17861
  },
17872
17862
  "src/Prebuilt/components/Notifications/Notifications.tsx": {
17873
- "bytesInOutput": 7974
17863
+ "bytesInOutput": 7971
17874
17864
  },
17875
17865
  "src/Prebuilt/components/Notifications/AutoplayBlockedModal.tsx": {
17876
17866
  "bytesInOutput": 1053
@@ -17948,7 +17938,7 @@
17948
17938
  "bytesInOutput": 651
17949
17939
  }
17950
17940
  },
17951
- "bytes": 1309377
17941
+ "bytes": 1309070
17952
17942
  }
17953
17943
  }
17954
17944
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "prebuilt",
11
11
  "roomkit"
12
12
  ],
13
- "version": "0.3.5-alpha.1",
13
+ "version": "0.3.5-alpha.2",
14
14
  "author": "100ms",
15
15
  "license": "MIT",
16
16
  "repository": {
@@ -82,11 +82,11 @@
82
82
  "react": ">=17.0.2 <19.0.0"
83
83
  },
84
84
  "dependencies": {
85
- "@100mslive/hls-player": "0.3.5-alpha.1",
85
+ "@100mslive/hls-player": "0.3.5-alpha.2",
86
86
  "@100mslive/hms-noise-cancellation": "0.0.1",
87
- "@100mslive/hms-virtual-background": "1.13.5-alpha.1",
88
- "@100mslive/react-icons": "0.10.5-alpha.1",
89
- "@100mslive/react-sdk": "0.10.5-alpha.1",
87
+ "@100mslive/hms-virtual-background": "1.13.5-alpha.2",
88
+ "@100mslive/react-icons": "0.10.5-alpha.2",
89
+ "@100mslive/react-sdk": "0.10.5-alpha.2",
90
90
  "@100mslive/types-prebuilt": "0.12.8",
91
91
  "@emoji-mart/data": "^1.0.6",
92
92
  "@emoji-mart/react": "^1.0.1",
@@ -122,5 +122,5 @@
122
122
  "uuid": "^8.3.2",
123
123
  "worker-timers": "^7.0.40"
124
124
  },
125
- "gitHead": "cbc32d4a832f2752887e91de078493454a49d69f"
125
+ "gitHead": "2612f221c9a7a7705261bf50d57fbca61aee6386"
126
126
  }
@@ -285,7 +285,6 @@ function AppRoutes({
285
285
  const roomLayout = useRoomLayout();
286
286
  const isNotificationsDisabled = useIsNotificationDisabled();
287
287
  const { activeState, rejoin } = useAppStateManager();
288
-
289
288
  return (
290
289
  <AppStateContext.Provider value={{ rejoin }}>
291
290
  <>
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useMemo, useRef } from 'react';
2
2
  import { useMedia } from 'react-use';
3
3
  import {
4
4
  HMSRoomState,
@@ -79,6 +79,17 @@ export const AppData = React.memo(() => {
79
79
  const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
80
80
  const isMobile = useMedia(cssConfig.media.md);
81
81
  const { isLocalVideoEnabled } = useAVToggle();
82
+ const sidepaneOpenedRef = useRef(false);
83
+
84
+ const defaultMediaURL = useMemo(() => {
85
+ const media = elements?.virtual_background?.background_media || [];
86
+ for (let i = 0; i < media.length; i++) {
87
+ if (media[i].default && media[i].url) {
88
+ return media[i].url;
89
+ }
90
+ }
91
+ return '';
92
+ }, [elements?.virtual_background?.background_media]);
82
93
 
83
94
  useEffect(() => {
84
95
  hmsActions.initAppData({
@@ -112,19 +123,12 @@ export const AppData = React.memo(() => {
112
123
  }, [preferences.subscribedNotifications, hmsActions]);
113
124
 
114
125
  useEffect(() => {
115
- let defaultMediaURL;
116
- elements?.virtual_background?.background_media?.forEach(media => {
117
- if (media.default && media.url) {
118
- defaultMediaURL = media.url;
119
- }
120
- });
121
- if (defaultMediaURL) {
126
+ if (defaultMediaURL && !sidepaneOpenedRef.current && !isMobile && isLocalVideoEnabled) {
122
127
  hmsActions.setAppData(APP_DATA.background, defaultMediaURL);
123
- if (isLocalVideoEnabled && !isMobile) {
124
- toggleVB();
125
- }
128
+ sidepaneOpenedRef.current = true;
129
+ toggleVB();
126
130
  }
127
- }, [hmsActions, elements?.virtual_background?.background_media, toggleVB, isLocalVideoEnabled, isMobile]);
131
+ }, [hmsActions, toggleVB, isLocalVideoEnabled, isMobile, defaultMediaURL]);
128
132
 
129
133
  return <ResetStreamingStart />;
130
134
  });
@@ -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
  };