Fix fire'n'forget task from blocking guest logins.

This commit is contained in:
Lucas Morgan
2023-07-07 16:46:26 -05:00
parent dacd0475f9
commit 8884d15d6e
4 changed files with 42 additions and 24 deletions

View File

@@ -45,8 +45,13 @@ public class AccountManager
Id = response.UserId,
WhichAccountPlatform = WhichAccountPlatform.Guest
});
await shogiSocket.OpenAsync(response.OneTimeToken.ToString());
await localStorage.SetAccountPlatform(WhichAccountPlatform.Guest);
// TODO: OpenAsync() sometimes doesn't return, probably because of the fire'n'forget task inside it. Figure that out.
await shogiSocket.OpenAsync(response.OneTimeToken.ToString());
}
else
{
throw new InvalidOperationException("Failed to get token from server during guest login.");
}
}
@@ -114,16 +119,19 @@ public class AccountManager
{
var platform = await localStorage.GetAccountPlatform();
await localStorage.DeleteAccountPlatform();
await accountState.SetUser(null);
if (platform == WhichAccountPlatform.Guest)
{
await shogiApi.GuestLogout();
await accountState.SetUser(null);
}
else if (platform == WhichAccountPlatform.Microsoft)
{
await accountState.SetUser(null);
navigation.NavigateToLogout("authentication/logout");
}
else
{
throw new InvalidOperationException("Tried to logout without a valid account platform.");
}
}
}