about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/IndexComponents
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/IndexComponents')
-rw-r--r--MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor23
1 files changed, 10 insertions, 13 deletions
diff --git a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
index 03a7145..1fc70f2 100644
--- a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
+++ b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor
@@ -1,10 +1,4 @@
-@using MatrixRoomUtils.Web.Classes
-@using System.Text.Json
-@using Blazored.LocalStorage
-@using MatrixRoomUtils.Core
 @using MatrixRoomUtils.Core.Extensions
-@using Index = MatrixRoomUtils.Web.Pages.Index
-@using System.ComponentModel.DataAnnotations
 @inject ILocalStorageService LocalStorage
 @inject NavigationManager NavigationManager
 
@@ -27,30 +21,33 @@
     private string? _avatarUrl { get; set; }
     private int _roomCount { get; set; } = 0;
 
-    protected override async Task OnInitializedAsync()
-    {
+    protected override async Task OnInitializedAsync() {
         var hs = await new AuthenticatedHomeServer(User.LoginResponse.UserId, User.AccessToken, User.LoginResponse.HomeServer).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;
-        _roomCount = (await hs.GetJoinedRooms()).Count;
+        try {
+            _roomCount = (await hs.GetJoinedRooms()).Count;
+        }
+        catch {
+            _roomCount = -1;
+        }
         await base.OnInitializedAsync();
     }
 
-    private async Task RemoveUser()
-    {
+    private async Task RemoveUser() {
         Console.WriteLine(User.ToJson());
         RuntimeCache.LoginSessions.Remove(User.AccessToken);
 
         StateHasChanged();
     }
 
-    private async Task SetCurrent()
-    {
+    private async Task SetCurrent() {
         RuntimeCache.LastUsedToken = User.AccessToken;
     //RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer);
         await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
         await LocalStorageWrapper.InitialiseRuntimeVariables(LocalStorage);
         StateHasChanged();
     }
+
 }
\ No newline at end of file