Correction du demarrage apres la modal d'authentification
This commit is contained in:
@@ -140,26 +140,15 @@
|
||||
=> user.FindFirst("email")?.Value
|
||||
?? "Session active";
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!firstRender)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_dotNetReference = DotNetObjectReference.Create(this);
|
||||
await JS.InvokeVoidAsync("chesscubingAuthModal.registerListener", _dotNetReference);
|
||||
_listenerRegistered = true;
|
||||
}
|
||||
|
||||
private void OpenLoginModal()
|
||||
=> OpenAuthModal("Se connecter", LoginHref);
|
||||
|
||||
private void OpenRegisterModal()
|
||||
=> OpenAuthModal("Creer un compte", RegisterHref);
|
||||
|
||||
private void OpenAuthModal(string title, string source)
|
||||
private async Task OpenLoginModal()
|
||||
=> await OpenAuthModalAsync("Se connecter", LoginHref);
|
||||
|
||||
private async Task OpenRegisterModal()
|
||||
=> await OpenAuthModalAsync("Creer un compte", RegisterHref);
|
||||
|
||||
private async Task OpenAuthModalAsync(string title, string source)
|
||||
{
|
||||
await EnsureAuthListenerAsync();
|
||||
AuthModalTitle = title;
|
||||
AuthModalSource = source;
|
||||
ShowAuthModal = true;
|
||||
@@ -171,6 +160,27 @@
|
||||
AuthModalSource = null;
|
||||
}
|
||||
|
||||
private async Task EnsureAuthListenerAsync()
|
||||
{
|
||||
if (_listenerRegistered)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_dotNetReference ??= DotNetObjectReference.Create(this);
|
||||
|
||||
try
|
||||
{
|
||||
await JS.InvokeVoidAsync("chesscubingAuthModal.registerListener", _dotNetReference);
|
||||
_listenerRegistered = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Si le navigateur garde encore un ancien script en cache,
|
||||
// on laisse l'application fonctionner et la modal reste utilisable sans auto-fermeture.
|
||||
}
|
||||
}
|
||||
|
||||
[JSInvokable]
|
||||
public Task HandleAuthModalMessage(string status)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user