Fix some bugs caused by order of operations.

This commit is contained in:
2023-05-14 19:53:47 -05:00
parent f21a170eb1
commit 841dbccc29
2 changed files with 11 additions and 6 deletions

View File

@@ -112,16 +112,17 @@ public class AccountManager
public async Task LogoutAsync() public async Task LogoutAsync()
{ {
await accountState.SetUser(null);
var platform = await localStorage.GetAccountPlatform(); var platform = await localStorage.GetAccountPlatform();
await localStorage.DeleteAccountPlatform(); await localStorage.DeleteAccountPlatform();
if (platform == WhichAccountPlatform.Guest) if (platform == WhichAccountPlatform.Guest)
{ {
await shogiApi.GuestLogout(); await shogiApi.GuestLogout();
await accountState.SetUser(null);
} }
else if (platform == WhichAccountPlatform.Microsoft) else if (platform == WhichAccountPlatform.Microsoft)
{ {
await accountState.SetUser(null);
navigation.NavigateToLogout("authentication/logout"); navigation.NavigateToLogout("authentication/logout");
} }
} }

View File

@@ -32,10 +32,14 @@ public class ShogiSocket : IDisposable
public async Task OpenAsync(string token) public async Task OpenAsync(string token)
{ {
uriBuilder.Query = new QueryBuilder if (this.socket.State == WebSocketState.Open)
{ {
{ "token", token } await this.socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing before opening a new connection.", CancellationToken.None);
}.ToQueryString().Value; }
uriBuilder.Query = new QueryBuilder { { "token", token } }.ToQueryString().Value;
Console.WriteLine("ShogiSocket.OpenAsync socket state is {0}", this.socket.State.ToString());
await socket.ConnectAsync(this.uriBuilder.Uri, cancelToken.Token); await socket.ConnectAsync(this.uriBuilder.Uri, cancelToken.Token);
// Fire and forget! I'm way too lazy to write my own javascript interop to a web worker. Nooo thanks. // Fire and forget! I'm way too lazy to write my own javascript interop to a web worker. Nooo thanks.
@@ -102,8 +106,8 @@ public class ShogiSocket : IDisposable
{ {
if (disposing) if (disposing)
{ {
//socket.Dispose(); // This is handled by the DI container.
cancelToken.Cancel(); cancelToken.Cancel();
socket.Dispose();
memoryOwner.Dispose(); memoryOwner.Dispose();
} }
disposedValue = true; disposedValue = true;