about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-19 02:36:32 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-19 02:36:32 +0200
commited2205972a7b7d6fdd4563c3775a83616920597a (patch)
tree54aec1cfdf861fd8a7739be131fbe79ae24d91e4 /MatrixRoomUtils.Web
parentPartial refactor (diff)
downloadMatrixUtils-ed2205972a7b7d6fdd4563c3775a83616920597a.tar.xz
Working sync
Diffstat (limited to 'MatrixRoomUtils.Web')
-rw-r--r--MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs17
-rw-r--r--MatrixRoomUtils.Web/Classes/SessionStorageProviderService.cs12
-rw-r--r--MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj4
-rw-r--r--MatrixRoomUtils.Web/Pages/LoginPage.razor2
-rw-r--r--MatrixRoomUtils.Web/Program.cs8
-rw-r--r--MatrixRoomUtils.Web/SessionStorageProviderService.cs5
-rw-r--r--MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor2
-rw-r--r--MatrixRoomUtils.Web/Shared/InlineUserItem.razor2
-rw-r--r--MatrixRoomUtils.Web/Shared/UserListItem.razor2
9 files changed, 29 insertions, 25 deletions
diff --git a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
index b7da78a..878eca4 100644
--- a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
+++ b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
@@ -10,19 +10,18 @@ public class LocalStorageWrapper {
     //some basic logic
     public static async Task InitialiseRuntimeVariables(ILocalStorageService localStorage) {
         //RuntimeCache stuff
-        async Task Save() => await SaveToLocalStorage(localStorage);
-        async Task SaveObject(string key, object obj) => await localStorage.SetItemAsync(key, obj);
-        async Task RemoveObject(string key) => await localStorage.RemoveItemAsync(key);
-        
-        RuntimeCache.Save = Save;
-        RuntimeCache.SaveObject = SaveObject;
-        RuntimeCache.RemoveObject = RemoveObject;
+        // async Task Save() => await SaveToLocalStorage(localStorage);
+        // async Task SaveObject(string key, object obj) => await localStorage.SetItemAsync(key, obj);
+        // async Task RemoveObject(string key) => await localStorage.RemoveItemAsync(key);
+        //
+        // RuntimeCache.Save = Save;
+        // RuntimeCache.SaveObject = SaveObject;
+        // RuntimeCache.RemoveObject = RemoveObject;
         if (RuntimeCache.LastUsedToken != null) {
             Console.WriteLine("Access token is not null, creating authenticated home server");
             Console.WriteLine($"Homeserver cache: {RuntimeCache.HomeserverResolutionCache.Count} entries");
             // Console.WriteLine(RuntimeCache.HomeserverResolutionCache.ToJson());
-            RuntimeCache.CurrentHomeServer = await new AuthenticatedHomeServer(RuntimeCache.LoginSessions[RuntimeCache.LastUsedToken].LoginResponse.UserId, RuntimeCache.LastUsedToken,
-                RuntimeCache.LoginSessions[RuntimeCache.LastUsedToken].LoginResponse.HomeServer).Configure();
+            RuntimeCache.CurrentHomeServer = await new AuthenticatedHomeServer(RuntimeCache.LoginSessions[RuntimeCache.LastUsedToken].LoginResponse.HomeServer, RuntimeCache.LastUsedToken, TODO).Configure();
             Console.WriteLine("Created authenticated home server");
         }
     }
diff --git a/MatrixRoomUtils.Web/Classes/SessionStorageProviderService.cs b/MatrixRoomUtils.Web/Classes/SessionStorageProviderService.cs
new file mode 100644
index 0000000..4a9c7d1
--- /dev/null
+++ b/MatrixRoomUtils.Web/Classes/SessionStorageProviderService.cs
@@ -0,0 +1,12 @@
+using Blazored.SessionStorage;
+using MatrixRoomUtils.Core.Interfaces.Services;
+
+namespace MatrixRoomUtils.Web; 
+
+public class SessionStorageProviderService : IStorageProvider {
+    private readonly ISessionStorageService _sessionStorage;
+
+    public SessionStorageProviderService(ISessionStorageService sessionStorage) {
+        _sessionStorage = sessionStorage;
+    }
+}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj b/MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj
index 33fb062..4bb7aeb 100644
--- a/MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj
+++ b/MatrixRoomUtils.Web/MatrixRoomUtils.Web.csproj
@@ -9,8 +9,8 @@
     <ItemGroup>
         <PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
         <PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
-        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.3" />
-        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.3" PrivateAssets="all" />
+        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.7" />
+        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.7" PrivateAssets="all" />
     </ItemGroup>
 
     <ItemGroup>
diff --git a/MatrixRoomUtils.Web/Pages/LoginPage.razor b/MatrixRoomUtils.Web/Pages/LoginPage.razor
index 16fdd24..3b78817 100644
--- a/MatrixRoomUtils.Web/Pages/LoginPage.razor
+++ b/MatrixRoomUtils.Web/Pages/LoginPage.razor
@@ -52,7 +52,7 @@
             var userinfo = new UserInfo {
                 LoginResponse = result
             };
-            userinfo.Profile = await (await new AuthenticatedHomeServer(result.UserId, result.AccessToken, result.HomeServer).Configure()).GetProfile(result.UserId);
+            userinfo.Profile = await (await new AuthenticatedHomeServer(result.HomeServer, result.AccessToken, TODO).Configure()).GetProfile(result.UserId);
             RuntimeCache.LastUsedToken = result.AccessToken;
 
             RuntimeCache.LoginSessions.Add(result.AccessToken, userinfo);
diff --git a/MatrixRoomUtils.Web/Program.cs b/MatrixRoomUtils.Web/Program.cs
index 11e7f19..b106543 100644
--- a/MatrixRoomUtils.Web/Program.cs
+++ b/MatrixRoomUtils.Web/Program.cs
@@ -32,12 +32,10 @@ builder.Services.AddBlazoredSessionStorage(config => {
     config.JsonSerializerOptions.WriteIndented = false;
 });
 
-builder.Services.AddScoped<LocalStorageProviderService>();
-builder.Services.AddSingleton<SessionStorageProviderService>();
-builder.Services.AddSingleton<TieredStorageService>(x =>
+builder.Services.AddScoped<TieredStorageService>(x =>
     new(
-        x.GetRequiredService<SessionStorageProviderService>(),
-        x.GetRequiredService<LocalStorageProviderService>()
+        cacheStorageProvider: new SessionStorageProviderService(x.GetRequiredService<ISessionStorageService>()),
+        dataStorageProvider: new LocalStorageProviderService(x.GetRequiredService<ILocalStorageService>())
     )
 );
 
diff --git a/MatrixRoomUtils.Web/SessionStorageProviderService.cs b/MatrixRoomUtils.Web/SessionStorageProviderService.cs
deleted file mode 100644
index d6bffe6..0000000
--- a/MatrixRoomUtils.Web/SessionStorageProviderService.cs
+++ /dev/null
@@ -1,5 +0,0 @@
-using MatrixRoomUtils.Core.Interfaces.Services;
-
-namespace MatrixRoomUtils.Web; 
-
-public class SessionStorageProviderService : IStorageProvider { }
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
index 1fc70f2..8ab44fb 100644
--- a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
+++ b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
@@ -22,7 +22,7 @@
     private int _roomCount { get; set; } = 0;
 
     protected override async Task OnInitializedAsync() {
-        var hs = await new AuthenticatedHomeServer(User.LoginResponse.UserId, User.AccessToken, User.LoginResponse.HomeServer).Configure();
+        var hs = await new AuthenticatedHomeServer(User.LoginResponse.HomeServer, User.AccessToken, TODO).Configure();
         if (User.Profile.AvatarUrl != null && User.Profile.AvatarUrl != "")
             _avatarUrl = hs.ResolveMediaUri(User.Profile.AvatarUrl);
         else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId;
diff --git a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
index 9833c62..43a4111 100644
--- a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
+++ b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
@@ -36,7 +36,7 @@
 
         await _semaphoreSlim.WaitAsync();
 
-        var hs = await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.UserId, RuntimeCache.CurrentHomeServer.AccessToken, RuntimeCache.CurrentHomeServer.HomeServerDomain).Configure();
+        var hs = await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.HomeServerDomain, RuntimeCache.CurrentHomeServer.AccessToken, TODO).Configure();
 
         if (User == null) {
             if (UserId == null) {
diff --git a/MatrixRoomUtils.Web/Shared/UserListItem.razor b/MatrixRoomUtils.Web/Shared/UserListItem.razor
index 43c71ab..b99671a 100644
--- a/MatrixRoomUtils.Web/Shared/UserListItem.razor
+++ b/MatrixRoomUtils.Web/Shared/UserListItem.razor
@@ -33,7 +33,7 @@
 
         await _semaphoreSlim.WaitAsync();
 
-        var hs = await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.UserId, RuntimeCache.CurrentHomeServer.AccessToken, RuntimeCache.CurrentHomeServer.HomeServerDomain).Configure();
+        var hs = await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.HomeServerDomain, RuntimeCache.CurrentHomeServer.AccessToken, TODO).Configure();
 
         if (User == null) {
             if (UserId == null) {