si le state persistant est stale ou absent, on accepte le démarrage plutôt que de déclencher l’exception de fond

This commit is contained in:
Paul Schneider 2026-11-14 21:10:33 +00:00
commit f282d14126
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12

View file

@ -30,10 +30,25 @@ internal static class ChatBootState
throw new IOException("Impossible d'enregistrer la deconnexion Android.");
}
internal static bool CanStart(YavscApiClient api) =>
OptedIn && Preferences.GetBoolean("signed-in", false)
&& api.Settings.AndroidKeepChatConnected && !api.IsSigningOut && api.HasValidSession
&& Identity(api) is { } identity && identity == Preferences.GetString("identity", null);
internal static bool CanStart(YavscApiClient api)
{
if (!OptedIn || !api.Settings.AndroidKeepChatConnected || api.IsSigningOut || !api.HasValidSession)
return false;
var identity = Identity(api);
if (identity is null) return false;
var signedIn = Preferences.GetBoolean("signed-in", false);
var storedIdentity = Preferences.GetString("identity", null);
// A valid refresh-capable session can coexist with stale native prefs
// (for example after app relaunch or an interrupted token renewal).
// Treat missing/lagging prefs as recoverable instead of rejecting the
// start outright, but keep strict identity matching when both values exist.
if (!signedIn && string.IsNullOrEmpty(storedIdentity)) return true;
if (signedIn && !string.IsNullOrEmpty(storedIdentity)) return identity == storedIdentity;
return true;
}
internal static string? Identity(YavscApiClient api)
{