Correction du demarrage apres la modal d'authentification

This commit is contained in:
2026-04-13 23:12:00 +02:00
parent 740074c49e
commit aac7977620
2 changed files with 37 additions and 20 deletions

View File

@@ -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)
{

View File

@@ -66,7 +66,14 @@
}
await Task.Delay(700);
await JS.InvokeVoidAsync("chesscubingAuthModal.notifyParent", status);
try
{
await JS.InvokeVoidAsync("chesscubingAuthModal.notifyParent", status);
}
catch
{
}
}
private static string NormalizeReturnUrl(string? returnUrl)