Skip to content

Commit eb9baab

Browse files
Do not refresh the CallComposite if no options has been changed.
1 parent 3ceacdc commit eb9baab

File tree

2 files changed

+771
-1
lines changed

2 files changed

+771
-1
lines changed

src/Communication.UI.Blazor/Calling/CallComposite.razor.cs

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public sealed partial class CallComposite
1818

1919
private ElementReference callContainer;
2020

21+
private CallControlOptions? lastControlOptions;
22+
2123
/// <summary>
2224
/// Gets or sets the <see cref="CallAdapter"/> which provides the logic and data of the composite control.
2325
/// The <see cref="CallComposite"/> can also be controlled using the adapter.
@@ -121,8 +123,68 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
121123
ScreenShareButton = this.ScreenShareButton,
122124
};
123125

124-
await adapter.Module.InvokeVoidAsync("initializeControl", this.callContainer, adapter.Id, options);
126+
if (this.ControlOptionsHasBeenChanged(options))
127+
{
128+
await adapter.Module.InvokeVoidAsync("initializeControl", this.callContainer, adapter.Id, options);
129+
130+
this.lastControlOptions = options;
131+
}
132+
}
133+
}
134+
135+
private bool ControlOptionsHasBeenChanged(CallControlOptions newOptions)
136+
{
137+
if (this.lastControlOptions is null)
138+
{
139+
return true;
125140
}
141+
142+
if (this.lastControlOptions.CameraButton != newOptions.CameraButton)
143+
{
144+
return true;
145+
}
146+
147+
if (this.lastControlOptions.DevicesButton != newOptions.DevicesButton)
148+
{
149+
return true;
150+
}
151+
152+
if (this.lastControlOptions.EndCallButton != newOptions.EndCallButton)
153+
{
154+
return true;
155+
}
156+
157+
if (this.lastControlOptions.MicrophoneButton != newOptions.MicrophoneButton)
158+
{
159+
return true;
160+
}
161+
162+
if (this.lastControlOptions.MoreButton != newOptions.MoreButton)
163+
{
164+
return true;
165+
}
166+
167+
if (this.lastControlOptions.ParticipantsButton != newOptions.ParticipantsButton)
168+
{
169+
return true;
170+
}
171+
172+
if (this.lastControlOptions.PeopleButton != newOptions.PeopleButton)
173+
{
174+
return true;
175+
}
176+
177+
if (this.lastControlOptions.RaiseHandButton != newOptions.RaiseHandButton)
178+
{
179+
return true;
180+
}
181+
182+
if (this.lastControlOptions.ScreenShareButton != newOptions.ScreenShareButton)
183+
{
184+
return true;
185+
}
186+
187+
return false;
126188
}
127189
}
128190
}

0 commit comments

Comments
 (0)