Skip to content

Commit 013de1f

Browse files
[Bug fix] CallId switch losing participants fix (#5725)
* update useAdapted selector to always use the up to date callId * Change files * fix build * remove callid from array --------- Co-authored-by: James Burnside <[email protected]>
1 parent 89dca28 commit 013de1f

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Calls",
5+
"comment": "update useAdapted selector to always use the up to date callId",
6+
"packageName": "@azure/communication-react",
7+
"email": "[email protected]",
8+
"dependentChangeType": "patch"
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Calls",
5+
"comment": "update useAdapted selector to always use the up to date callId",
6+
"packageName": "@azure/communication-react",
7+
"email": "[email protected]",
8+
"dependentChangeType": "patch"
9+
}

packages/react-composites/src/composites/CallComposite/hooks/useAdaptedSelector.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/* eslint-disable @typescript-eslint/no-explicit-any */
55

6-
import { useState, useEffect, useRef, useMemo } from 'react';
6+
import { useState, useEffect, useRef } from 'react';
77

88
import memoizeOne from 'memoize-one';
99
import { useAdapter } from '../adapter/CallAdapterProvider';
@@ -52,14 +52,8 @@ export const useSelectorWithAdaptation = <
5252
});
5353

5454
const callId = adapter.getState().call?.id;
55-
const callConfigProps = useMemo(
56-
() => ({
57-
callId
58-
}),
59-
[callId]
60-
);
6155

62-
const [props, setProps] = useState(selector(adaptState(adapter.getState()), selectorProps ?? callConfigProps));
56+
const [props, setProps] = useState(selector(adaptState(adapter.getState()), selectorProps ?? { callId }));
6357
const propRef = useRef(props);
6458
propRef.current = props;
6559

@@ -68,7 +62,7 @@ export const useSelectorWithAdaptation = <
6862
if (!mounted.current) {
6963
return;
7064
}
71-
const newProps = selector(adaptState(state), selectorProps ?? callConfigProps);
65+
const newProps = selector(adaptState(state), selectorProps ?? { callId: state.call?.id });
7266
if (propRef.current !== newProps) {
7367
setProps(newProps);
7468
}
@@ -77,7 +71,7 @@ export const useSelectorWithAdaptation = <
7771
return () => {
7872
adapter.offStateChange(onStateChange);
7973
};
80-
}, [adaptState, adapter, selector, selectorProps, callConfigProps]);
74+
}, [adaptState, adapter, selector, selectorProps]);
8175
return props;
8276
};
8377

0 commit comments

Comments
 (0)