UserListItem.razor (1911B)
1 @using MatrixRoomUtils.Core.Responses 2 <div style="background-color: #ffffff11; border-radius: 25px; margin: 8px; width: fit-Content;"> 3 <img style="@(ChildContent != null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@profileAvatar"/> 4 <span style="vertical-align: middle; margin-right: 8px; border-radius: 75px;">@profileName</span> 5 6 <div style="display: inline-block;"> 7 @if (ChildContent != null) 8 { 9 @ChildContent 10 } 11 </div> 12 13 </div> 14 15 @code { 16 17 [Parameter] 18 public RenderFragment? ChildContent { get; set; } 19 20 [Parameter] 21 public ProfileResponse User { get; set; } 22 23 [Parameter] 24 public string UserId { get; set; } 25 26 private string profileAvatar { get; set; } = "/icon-192.png"; 27 private string profileName { get; set; } = "Loading..."; 28 29 30 private static SemaphoreSlim _semaphoreSlim = new(128); 31 32 protected override async Task OnInitializedAsync() 33 { 34 await base.OnInitializedAsync(); 35 await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); 36 37 await _semaphoreSlim.WaitAsync(); 38 39 var hs = await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.UserId, RuntimeCache.CurrentHomeServer.AccessToken, RuntimeCache.CurrentHomeServer.HomeServerDomain).Configure(); 40 41 if (User == null) 42 { 43 if (UserId == null) 44 { 45 throw new ArgumentNullException(nameof(UserId)); 46 } 47 User = await hs.GetProfile(UserId); 48 } 49 else 50 { 51 // UserId = User.; 52 } 53 54 profileAvatar = RuntimeCache.CurrentHomeServer.ResolveMediaUri(User.AvatarUrl); 55 profileName = User.DisplayName; 56 57 _semaphoreSlim.Release(); 58 if (Random.Shared.Next(100) == 1) 59 await LocalStorageWrapper.SaveCacheToLocalStorage(LocalStorage); 60 } 61 62 }