Browse Source

LoginDisplay unsubscribe from AuthenticationStateChanged

pull/10608/head
Halil İbrahim Kalkan 4 years ago
parent
commit
d6e354e8bf
  1. 2
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/NavMenu.razor.cs
  2. 18
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs

2
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/NavMenu.razor.cs

@ -30,7 +30,7 @@ namespace Volo.Abp.AspNetCore.Components.Web.BasicTheme.Themes.Basic
private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task<AuthenticationState> task) private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task<AuthenticationState> task)
{ {
Menu = await MenuManager.GetMainMenuAsync(); Menu = await MenuManager.GetMainMenuAsync();
StateHasChanged(); await InvokeAsync(StateHasChanged);
} }
} }
} }

18
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs

@ -34,11 +34,8 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
if (AuthenticationStateProvider != null) if (AuthenticationStateProvider != null)
{ {
AuthenticationStateProvider.AuthenticationStateChanged += async (task) => AuthenticationStateProvider.AuthenticationStateChanged +=
{ AuthenticationStateProviderOnAuthenticationStateChanged;
Menu = await MenuManager.GetAsync(StandardMenus.User);
await InvokeAsync(StateHasChanged);
};
} }
} }
@ -46,10 +43,21 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
{ {
InvokeAsync(StateHasChanged); InvokeAsync(StateHasChanged);
} }
private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task<AuthenticationState> task)
{
Menu = await MenuManager.GetAsync(StandardMenus.User);
await InvokeAsync(StateHasChanged);
}
public void Dispose() public void Dispose()
{ {
Navigation.LocationChanged -= OnLocationChanged; Navigation.LocationChanged -= OnLocationChanged;
if (AuthenticationStateProvider != null)
{
AuthenticationStateProvider.AuthenticationStateChanged -=
AuthenticationStateProviderOnAuthenticationStateChanged;
}
} }
private async Task NavigateToAsync(string uri, string target = null) private async Task NavigateToAsync(string uri, string target = null)

Loading…
Cancel
Save