about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-03 20:42:20 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-03 20:42:20 +0200
commitb02fb81a56bd94b38fdb26771c3e591419f0f49c (patch)
tree617538d36ff9be9ba0f5d13cb6076b02f017a91b /MatrixRoomUtils.Web/Shared
parentRefactor (diff)
downloadMatrixUtils-b02fb81a56bd94b38fdb26771c3e591419f0f49c.tar.xz
Small refactoring
Diffstat (limited to 'MatrixRoomUtils.Web/Shared')
-rw-r--r--MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor15
-rw-r--r--MatrixRoomUtils.Web/Shared/MainLayout.razor12
2 files changed, 6 insertions, 21 deletions
diff --git a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
index 33054e5..d0fb2f0 100644
--- a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
+++ b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
@@ -9,14 +9,12 @@
 
 <div style="margin-bottom: 1em;">
     <img style="border-radius: 50%; height: 3em; width: 3em;" src="@_avatarUrl"/>
-    <span style="margin-left: 1em;"><input type="radio" name="csa" checked="@(LocalStorageWrapper.AccessToken == Token)" onclick="@SetCurrent" style="text-decoration-line: unset;"/> <b>@User.Profile.DisplayName</b> on <b>@User.LoginResponse.HomeServer</b></span>
+    <span style="margin-left: 1em;"><input type="radio" name="csa" checked="@(RuntimeCache.AccessToken == User.AccessToken)" onclick="@SetCurrent" style="text-decoration-line: unset;"/> <b>@User.Profile.DisplayName</b> on <b>@User.LoginResponse.HomeServer</b></span>
     <a href="#" onclick="@RemoveUser">Remove</a>
 </div>
 
 @code {
     [Parameter]
-    public string Token { get; set; }
-    [Parameter]
     public UserInfo User { get; set; }
     
     private string _avatarUrl { get; set; }
@@ -32,18 +30,17 @@
 
     private async Task RemoveUser()
     {
-        LocalStorageWrapper.LoginSessions.Remove(Token);
-        await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
+        RuntimeCache.LoginSessions.Remove(User.AccessToken);
+        await LocalStorageWrapper.ReloadLocalStorage(LocalStorage);
         _removed = true;
         
         StateHasChanged();
     }
     private async Task SetCurrent()
     {
-        LocalStorageWrapper.AccessToken = Token;
-        LocalStorageWrapper.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer);
-        await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
-        await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
+        RuntimeCache.AccessToken = User.AccessToken;
+        //RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer);
+        await LocalStorageWrapper.ReloadLocalStorage(LocalStorage);
         
         StateHasChanged();
     }
diff --git a/MatrixRoomUtils.Web/Shared/MainLayout.razor b/MatrixRoomUtils.Web/Shared/MainLayout.razor
index ae7c3f5..055cec7 100644
--- a/MatrixRoomUtils.Web/Shared/MainLayout.razor
+++ b/MatrixRoomUtils.Web/Shared/MainLayout.razor
@@ -1,7 +1,4 @@
 @inherits LayoutComponentBase
-
-@using Blazored.LocalStorage
-@using MatrixRoomUtils.Web.Classes
 @inject ILocalStorageService LocalStorage
 @inject NavigationManager NavigationManager
 
@@ -23,14 +20,5 @@
 
 @code {
 
-    protected override async Task OnInitializedAsync()
-    {
-        if (!LocalStorageWrapper.WasLoaded)
-        {
-            await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
-            Console.WriteLine("Loaded from local storage");
-            StateHasChanged();
-        }
-    }
 
 }
\ No newline at end of file