Refactor theme change handler for safe async updates
Refactored OnThemeChanged in MainLayout.razor to use InvokeAsync for proper synchronization of UI updates and async logic, preventing threading issues. Also added a blank line after app.Run() in Program.cs (no functional impact).
This commit is contained in:
@@ -50,13 +50,14 @@
|
|||||||
await ApplyDxDarkOverrideAsync();
|
await ApplyDxDarkOverrideAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnThemeChanged()
|
private void OnThemeChanged()
|
||||||
{
|
{
|
||||||
StateHasChanged();
|
InvokeAsync(async () =>
|
||||||
if (_isInteractive)
|
|
||||||
{
|
{
|
||||||
await ApplyDxDarkOverrideAsync();
|
StateHasChanged();
|
||||||
}
|
if (_isInteractive)
|
||||||
|
await ApplyDxDarkOverrideAsync();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ApplyDxDarkOverrideAsync()
|
private async Task ApplyDxDarkOverrideAsync()
|
||||||
|
|||||||
@@ -44,4 +44,4 @@ app.UseAntiforgery();
|
|||||||
app.MapRazorComponents<App>()
|
app.MapRazorComponents<App>()
|
||||||
.AddInteractiveServerRenderMode();
|
.AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
Reference in New Issue
Block a user