Replace custom socket implementation with SignalR.

Replace MSAL and custom cookie auth with Microsoft.Identity.EntityFramework
Also some UI redesign to accommodate different login experience.
This commit is contained in:
2024-08-25 03:46:44 +00:00
parent d688afaeae
commit 51d234d871
172 changed files with 3857 additions and 4045 deletions

View File

@@ -2,50 +2,49 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Shogi.UI.Shared
namespace Shogi.UI.Shared;
public class LocalStorage : ILocalStorage
{
public class LocalStorage : ILocalStorage
private readonly JsonSerializerOptions jsonOptions;
private readonly IJSRuntime jSRuntime;
public LocalStorage(IJSRuntime jSRuntime)
{
private readonly JsonSerializerOptions jsonOptions;
private readonly IJSRuntime jSRuntime;
this.jsonOptions = new JsonSerializerOptions();
this.jsonOptions.Converters.Add(new JsonStringEnumConverter());
this.jSRuntime = jSRuntime;
}
public LocalStorage(IJSRuntime jSRuntime)
public ValueTask Set<T>(string key, T value)
{
var serialized = JsonSerializer.Serialize(value);
return this.jSRuntime.InvokeVoidAsync("localStorage.setItem", key, serialized);
}
public async ValueTask<T?> Get<T>(string key) where T : struct
{
var value = await this.jSRuntime.InvokeAsync<string>("localStorage.getItem", key);
try
{
jsonOptions = new JsonSerializerOptions();
jsonOptions.Converters.Add(new JsonStringEnumConverter());
this.jSRuntime = jSRuntime;
return JsonSerializer.Deserialize<T>(value, this.jsonOptions);
}
public ValueTask Set<T>(string key, T value)
catch (ArgumentNullException)
{
var serialized = JsonSerializer.Serialize(value);
return jSRuntime.InvokeVoidAsync("localStorage.setItem", key, serialized);
}
public async ValueTask<T?> Get<T>(string key) where T : struct
{
var value = await jSRuntime.InvokeAsync<string>("localStorage.getItem", key);
try
{
return JsonSerializer.Deserialize<T>(value, jsonOptions);
}
catch (ArgumentNullException)
{
return default;
}
}
public ValueTask Delete(string key)
{
return jSRuntime.InvokeVoidAsync("localStorage.removeItem", key);
return default;
}
}
public interface ILocalStorage
public ValueTask Delete(string key)
{
ValueTask Delete(string key);
ValueTask<T?> Get<T>(string key) where T : struct;
ValueTask Set<T>(string key, T value);
return this.jSRuntime.InvokeVoidAsync("localStorage.removeItem", key);
}
}
public interface ILocalStorage
{
ValueTask Delete(string key);
ValueTask<T?> Get<T>(string key) where T : struct;
ValueTask Set<T>(string key, T value);
}