Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fix whole app re-render when callId changes",
"packageName": "@internal/react-composites",
"email": "jiangnanhello@live.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class CallContext {
this.setState({ ...this.state, isLocalPreviewMicrophoneEnabled });
}

public setCallId(callId: string | undefined): void {
// This is the key to find current call object in client state
public setCurrentCallId(callId: string | undefined): void {
this.callId = callId;
}

Expand Down Expand Up @@ -170,6 +171,15 @@ export class AzureCommunicationCallAdapter implements CallAdapter {
callClient.offStateChange(onStateChange);
return;
}

// `updateClientState` searches for the current call from all the calls in the state using a cached `call.id`
// from the call object. `call.id` can change during a call. We must update the cached `call.id` before
// calling `updateClientState` so that we find the correct state object for the call even when `call.id`
// has changed.
// https://github.com/Azure/communication-ui-library/pull/1820
if (this.call?.id) {
Comment thread
prprabhu-ms marked this conversation as resolved.
this.context.setCurrentCallId(this.call.id);
}
this.context.updateClientState(clientState);
};

Expand Down Expand Up @@ -293,7 +303,7 @@ export class AzureCommunicationCallAdapter implements CallAdapter {
this.unsubscribeCallEvents();
this.call = undefined;
this.handlers = createDefaultCallingHandlers(this.callClient, this.callAgent, this.deviceManager, undefined);
this.context.setCallId(undefined);
this.context.setCurrentCallId(undefined);
// Resync state after callId is set
this.context.updateClientState(this.callClient.getState());
this.stopCamera();
Expand Down Expand Up @@ -393,7 +403,7 @@ export class AzureCommunicationCallAdapter implements CallAdapter {

private processNewCall(call: Call): void {
this.call = call;
this.context.setCallId(call.id);
this.context.setCurrentCallId(call.id);

// Resync state after callId is set
this.context.updateClientState(this.callClient.getState());
Expand Down Expand Up @@ -491,9 +501,6 @@ export class AzureCommunicationCallAdapter implements CallAdapter {
}

private callIdChanged(): void {
this.context.setCallId(this.call?.id);
// Resync state after callId is set
this.context.updateClientState(this.callClient.getState());
this.emitter.emit('callIdChanged', { callId: this.callIdChanged.bind(this) });
}

Expand Down