@stream-io/video-react-sdk 1.7.13 → 1.7.15
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/CHANGELOG.md +13 -0
- package/dist/index.cjs.js +28 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +29 -7
- package/dist/index.es.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/usePersistedDevicePreferences.ts +29 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.7.15](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.14...@stream-io/video-react-sdk-1.7.15) (2024-11-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* race conditions in usePersistedDevicePreferences ([#1575](https://github.com/GetStream/stream-video-js/issues/1575)) ([08aacc4](https://github.com/GetStream/stream-video-js/commit/08aacc4e35920e30d9f091ba9207ecf757d86796))
|
|
11
|
+
|
|
12
|
+
## [1.7.14](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.13...@stream-io/video-react-sdk-1.7.14) (2024-11-13)
|
|
13
|
+
|
|
14
|
+
### Dependency Updates
|
|
15
|
+
|
|
16
|
+
* `@stream-io/video-client` updated to version `1.11.0`
|
|
17
|
+
* `@stream-io/video-react-bindings` updated to version `1.1.17`
|
|
5
18
|
## [1.7.13](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.12...@stream-io/video-react-sdk-1.7.13) (2024-11-12)
|
|
6
19
|
|
|
7
20
|
### Dependency Updates
|
package/dist/index.cjs.js
CHANGED
|
@@ -79,13 +79,15 @@ const defaultDevice = 'default';
|
|
|
79
79
|
*
|
|
80
80
|
* @param key the key to use for local storage.
|
|
81
81
|
*/
|
|
82
|
-
const usePersistDevicePreferences = (key) => {
|
|
82
|
+
const usePersistDevicePreferences = (key, shouldPersistRef) => {
|
|
83
83
|
const { useMicrophoneState, useCameraState, useSpeakerState } = videoReactBindings.useCallStateHooks();
|
|
84
84
|
const call = videoReactBindings.useCall();
|
|
85
85
|
const mic = useMicrophoneState();
|
|
86
86
|
const camera = useCameraState();
|
|
87
87
|
const speaker = useSpeakerState();
|
|
88
88
|
react.useEffect(() => {
|
|
89
|
+
if (!shouldPersistRef.current)
|
|
90
|
+
return;
|
|
89
91
|
if (!call)
|
|
90
92
|
return;
|
|
91
93
|
if (call.state.callingState === videoClient.CallingState.LEFT)
|
|
@@ -118,6 +120,7 @@ const usePersistDevicePreferences = (key) => {
|
|
|
118
120
|
mic.isMute,
|
|
119
121
|
mic.selectedDevice,
|
|
120
122
|
speaker.selectedDevice,
|
|
123
|
+
shouldPersistRef,
|
|
121
124
|
]);
|
|
122
125
|
};
|
|
123
126
|
/**
|
|
@@ -125,16 +128,23 @@ const usePersistDevicePreferences = (key) => {
|
|
|
125
128
|
*
|
|
126
129
|
* @param key the key to use for local storage.
|
|
127
130
|
*/
|
|
128
|
-
const useApplyDevicePreferences = (key) => {
|
|
131
|
+
const useApplyDevicePreferences = (key, onApplied) => {
|
|
129
132
|
const call = videoReactBindings.useCall();
|
|
133
|
+
const onAppliedRef = react.useRef(onApplied);
|
|
134
|
+
onAppliedRef.current = onApplied;
|
|
130
135
|
react.useEffect(() => {
|
|
131
136
|
if (!call)
|
|
132
137
|
return;
|
|
133
138
|
if (call.state.callingState === videoClient.CallingState.LEFT)
|
|
134
139
|
return;
|
|
140
|
+
let cancel = false;
|
|
135
141
|
const apply = async () => {
|
|
136
142
|
const initMic = async (setting) => {
|
|
143
|
+
if (cancel)
|
|
144
|
+
return;
|
|
137
145
|
await call.microphone.select(parseDeviceId(setting.selectedDeviceId));
|
|
146
|
+
if (cancel)
|
|
147
|
+
return;
|
|
138
148
|
if (setting.muted) {
|
|
139
149
|
await call.microphone.disable();
|
|
140
150
|
}
|
|
@@ -143,7 +153,11 @@ const useApplyDevicePreferences = (key) => {
|
|
|
143
153
|
}
|
|
144
154
|
};
|
|
145
155
|
const initCamera = async (setting) => {
|
|
156
|
+
if (cancel)
|
|
157
|
+
return;
|
|
146
158
|
await call.camera.select(parseDeviceId(setting.selectedDeviceId));
|
|
159
|
+
if (cancel)
|
|
160
|
+
return;
|
|
147
161
|
if (setting.muted) {
|
|
148
162
|
await call.camera.disable();
|
|
149
163
|
}
|
|
@@ -152,6 +166,8 @@ const useApplyDevicePreferences = (key) => {
|
|
|
152
166
|
}
|
|
153
167
|
};
|
|
154
168
|
const initSpeaker = (setting) => {
|
|
169
|
+
if (cancel)
|
|
170
|
+
return;
|
|
155
171
|
call.speaker.select(parseDeviceId(setting.selectedDeviceId) ?? '');
|
|
156
172
|
};
|
|
157
173
|
let preferences = null;
|
|
@@ -167,9 +183,14 @@ const useApplyDevicePreferences = (key) => {
|
|
|
167
183
|
initSpeaker(preferences.speaker);
|
|
168
184
|
}
|
|
169
185
|
};
|
|
170
|
-
apply()
|
|
186
|
+
apply()
|
|
187
|
+
.then(() => onAppliedRef.current())
|
|
188
|
+
.catch((err) => {
|
|
171
189
|
console.warn('Failed to apply device preferences', err);
|
|
172
190
|
});
|
|
191
|
+
return () => {
|
|
192
|
+
cancel = true;
|
|
193
|
+
};
|
|
173
194
|
}, [call, key]);
|
|
174
195
|
};
|
|
175
196
|
/**
|
|
@@ -178,8 +199,9 @@ const useApplyDevicePreferences = (key) => {
|
|
|
178
199
|
* @param key the key to use for local storage.
|
|
179
200
|
*/
|
|
180
201
|
const usePersistedDevicePreferences = (key = '@stream-io/device-preferences') => {
|
|
181
|
-
|
|
182
|
-
|
|
202
|
+
const shouldPersistRef = react.useRef(false);
|
|
203
|
+
useApplyDevicePreferences(key, () => (shouldPersistRef.current = true));
|
|
204
|
+
usePersistDevicePreferences(key, shouldPersistRef);
|
|
183
205
|
};
|
|
184
206
|
const parseDeviceId = (deviceId) => deviceId !== defaultDevice ? deviceId : undefined;
|
|
185
207
|
|
|
@@ -2529,7 +2551,7 @@ const LivestreamPlayer = (props) => {
|
|
|
2529
2551
|
return (jsxRuntime.jsx(StreamCall, { call: call, children: jsxRuntime.jsx(LivestreamLayout, { ...layoutProps }) }));
|
|
2530
2552
|
};
|
|
2531
2553
|
|
|
2532
|
-
const [major, minor, patch] = ("1.7.
|
|
2554
|
+
const [major, minor, patch] = ("1.7.15").split('.');
|
|
2533
2555
|
videoClient.setSdkInfo({
|
|
2534
2556
|
type: videoClient.SfuModels.SdkType.REACT,
|
|
2535
2557
|
major,
|