about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Web')
-rw-r--r--MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs2
-rw-r--r--MatrixRoomUtils.Web/Shared/NavMenu.razor9
-rw-r--r--MatrixRoomUtils.Web/Shared/RoomListItem.razor10
3 files changed, 20 insertions, 1 deletions
diff --git a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
index 5a13c49..287d1e5 100644
--- a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
+++ b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs
@@ -28,6 +28,7 @@ public partial class LocalStorageWrapper
             RuntimeCache.CurrentHomeServer = await new AuthenticatedHomeServer(RuntimeCache.LoginSessions[RuntimeCache.LastUsedToken].LoginResponse.UserId, RuntimeCache.LastUsedToken, RuntimeCache.LoginSessions[RuntimeCache.LastUsedToken].LoginResponse.HomeServer).Configure();
             Console.WriteLine("Created authenticated home server");
         }
+        RuntimeCache.GenericResponseCache = await localStorage.GetItemAsync<Dictionary<string, ObjectCache<object>>>("rory.matrixroomutils.generic_cache") ?? new();
         RuntimeCache.WasLoaded = true;
     }
 
@@ -40,5 +41,6 @@ public partial class LocalStorageWrapper
         await localStorage.SetItemAsync("rory.matrixroomutils.homeserver_resolution_cache", 
             RuntimeCache.HomeserverResolutionCache.DistinctBy(x => x.Key)
                 .ToDictionary(x => x.Key, x => x.Value));
+        await localStorage.SetItemAsync("rory.matrixroomutils.generic_cache", RuntimeCache.GenericResponseCache);
     }
 }
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/NavMenu.razor b/MatrixRoomUtils.Web/Shared/NavMenu.razor
index 0027901..a033925 100644
--- a/MatrixRoomUtils.Web/Shared/NavMenu.razor
+++ b/MatrixRoomUtils.Web/Shared/NavMenu.razor
@@ -15,6 +15,10 @@
             </NavLink>
         </div>
         <div class="nav-item px-3">
+            <h5 style="margin-left: 1em;">Main tools</h5>
+            <hr style="margin-bottom: 0em;"/>
+        </div>
+        <div class="nav-item px-3">
             <NavLink class="nav-link" href="About">
                 <span class="oi oi-plus" aria-hidden="true"></span> About MRU
             </NavLink>
@@ -39,6 +43,11 @@
                 <span class="oi oi-plus" aria-hidden="true"></span> Room state viewer
             </NavLink>
         </div>
+        <div class="nav-item px-3">
+            <h5 style="margin-left: 1em;">Plural tools</h5>
+            <hr style="margin-bottom: 0em;"/>
+        </div>
+
     </nav>
 </div>
 
diff --git a/MatrixRoomUtils.Web/Shared/RoomListItem.razor b/MatrixRoomUtils.Web/Shared/RoomListItem.razor
index d2c844d..15ca5c0 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListItem.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListItem.razor
@@ -33,6 +33,12 @@
     protected override async Task OnInitializedAsync()
     {
         await base.OnInitializedAsync();
+        
+        if(!RuntimeCache.WasLoaded) {
+            Console.WriteLine("Loading from local storage");
+            await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
+        }
+
         if (Room == null)
         {
             if (RoomId == null)
@@ -80,7 +86,7 @@
                 {
                     hasCustomProfileName = _name.GetString() != profile.DisplayName;
                     profileName = _name.GetString();
-                    Console.WriteLine($"{profile.DisplayName} - {_name.GetString()}: {hasCustomProfileName}");
+                    // Console.WriteLine($"{profile.DisplayName} - {_name.GetString()}: {hasCustomProfileName}");
                 }
                 else
                 {
@@ -88,6 +94,8 @@
                 }
             }
         }
+        if(Random.Shared.Next(100) == 1)
+            await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
     }
 
 }
\ No newline at end of file