@stream-io/video-react-sdk 1.18.3 → 1.18.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-react-sdk",
3
- "version": "1.18.3",
3
+ "version": "1.18.5",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "types": "./dist/index.d.ts",
@@ -30,9 +30,9 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "@floating-ui/react": "^0.27.6",
33
- "@stream-io/video-client": "1.23.4",
33
+ "@stream-io/video-client": "1.24.0",
34
34
  "@stream-io/video-filters-web": "0.2.1",
35
- "@stream-io/video-react-bindings": "1.6.7",
35
+ "@stream-io/video-react-bindings": "1.7.0",
36
36
  "chart.js": "^4.4.4",
37
37
  "clsx": "^2.0.0",
38
38
  "react-chartjs-2": "^5.3.0"
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { CallingState } from '@stream-io/video-client';
2
+ import { CallingState, InputDeviceStatus } from '@stream-io/video-client';
3
3
  import { useCallStateHooks } from '@stream-io/video-react-bindings';
4
4
 
5
5
  export type LocalDevicePreference = {
@@ -25,7 +25,7 @@ type DeviceState<K extends DeviceKey> = {
25
25
  };
26
26
 
27
27
  interface DeviceManagerLike {
28
- state: { selectedDevice: string | undefined };
28
+ state: { selectedDevice: string | undefined; status?: InputDeviceStatus };
29
29
  select: (deviceId: string) => Promise<void> | void;
30
30
  enable?: () => Promise<void>;
31
31
  disable?: () => Promise<void>;
@@ -86,22 +86,20 @@ export const usePersistedDevicePreferences = (
86
86
  state as DeviceState<'camera' | 'microphone' | 'speaker'>
87
87
  )[deviceKey];
88
88
 
89
- if (!manager.state.selectedDevice) {
90
- const applyPromise = preference
91
- ? applyLocalDevicePreference(
92
- manager,
93
- [preference].flat(),
94
- state.devices,
95
- )
96
- : applyMutedState(manager, defaultMuted);
97
-
98
- await applyPromise.catch((err) => {
99
- console.warn(
100
- `Failed to apply ${deviceKey} device preferences`,
101
- err,
102
- );
103
- });
104
- }
89
+ const applyPromise = preference
90
+ ? applyLocalDevicePreference(
91
+ manager,
92
+ [preference].flat(),
93
+ state.devices,
94
+ )
95
+ : applyMutedState(manager, defaultMuted);
96
+
97
+ await applyPromise.catch((err) => {
98
+ console.warn(
99
+ `Failed to apply ${deviceKey} device preferences`,
100
+ err,
101
+ );
102
+ });
105
103
  }
106
104
  })().finally(() =>
107
105
  setApplyingState((state) => (state === 'applying' ? 'applied' : state)),
@@ -344,7 +342,10 @@ const applyLocalDevicePreference = async (
344
342
  devices.find((d) => d.label === p.selectedDeviceLabel);
345
343
 
346
344
  if (device) {
347
- await manager.select(device.deviceId);
345
+ if (!manager.state.selectedDevice) {
346
+ await manager.select(device.deviceId);
347
+ }
348
+
348
349
  muted = p.muted;
349
350
  break;
350
351
  }
@@ -356,7 +357,9 @@ const applyLocalDevicePreference = async (
356
357
  };
357
358
 
358
359
  const applyMutedState = async (manager: DeviceManagerLike, muted: boolean) => {
359
- await manager[muted ? 'disable' : 'enable']?.();
360
+ if (!manager.state.status) {
361
+ await manager[muted ? 'disable' : 'enable']?.();
362
+ }
360
363
  };
361
364
 
362
365
  const getSelectedDevicePreference = (
@@ -108,7 +108,7 @@ const useLivestreamCall = (props: {
108
108
  const call = useCall();
109
109
  const { useIsCallLive, useOwnCapabilities } = useCallStateHooks();
110
110
  const canJoinLive = useIsCallLive();
111
- const canJoinEarly = useCanJoinEearly();
111
+ const canJoinEarly = useCanJoinEarly();
112
112
  const canJoinBackstage =
113
113
  useOwnCapabilities()?.includes('join-backstage') ?? false;
114
114
  const canJoinAsap = canJoinLive || canJoinEarly || canJoinBackstage;
@@ -130,24 +130,26 @@ const useLivestreamCall = (props: {
130
130
  return call;
131
131
  };
132
132
 
133
- const useCanJoinEearly = () => {
133
+ const useCanJoinEarly = () => {
134
134
  const { useCallStartsAt, useCallSettings } = useCallStateHooks();
135
135
  const startsAt = useCallStartsAt();
136
136
  const settings = useCallSettings();
137
137
  const joinAheadTimeSeconds = settings?.backstage.join_ahead_time_seconds;
138
- const [canJoinEarly, setCanJoinEearly] = useState(() =>
138
+ const [canJoinEarly, setCanJoinEarly] = useState(() =>
139
139
  checkCanJoinEarly(startsAt, joinAheadTimeSeconds),
140
140
  );
141
141
 
142
142
  useEffect(() => {
143
143
  if (!canJoinEarly) {
144
144
  const handle = setInterval(() => {
145
- setCanJoinEearly(checkCanJoinEarly(startsAt, joinAheadTimeSeconds));
145
+ setCanJoinEarly(checkCanJoinEarly(startsAt, joinAheadTimeSeconds));
146
146
  }, 1000);
147
147
 
148
148
  return () => clearInterval(handle);
149
149
  }
150
150
  }, [canJoinEarly, startsAt, joinAheadTimeSeconds]);
151
+
152
+ return canJoinEarly;
151
153
  };
152
154
 
153
155
  const checkCanJoinEarly = (