WIP
This commit is contained in:
1 parent
08eefe2973
commit
2cf6128a85
10 files changed
+130
-12
No files matched your search
@@ -1,5 +1,7 @@
|
||||
@inject AccountService AccountService
|
||||
@inject AuthenticationStateProvider AuthStateProvider
|
||||
@inject AppState AppState
|
||||
@implements IDisposable
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<div class="top-row ps-3 navbar navbar-dark">
|
||||
@@ -74,6 +76,8 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
AppState.OnAccountsChanged += HandleAccountsChanged;
|
||||
|
||||
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||
var userId = authState.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
@@ -82,5 +86,22 @@
|
||||
accounts = await AccountService.GetAccountsAsync(userId);
|
||||
}
|
||||
}
|
||||
|
||||
private async void HandleAccountsChanged()
|
||||
{
|
||||
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||
var userId = authState.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
if (userId is not null)
|
||||
{
|
||||
accounts = await AccountService.GetAccountsAsync(userId);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
AppState.OnAccountsChanged -= HandleAccountsChanged;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user