@using LibMatrix @using LibMatrix.EventTypes.Spec.State @using LibMatrix.Helpers @using LibMatrix.Homeservers
@ProfileName
@if (ChildContent is not null) { @ChildContent }
@code { [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public ProfileResponseEventContent User { get; set; } [Parameter] public ProfileResponseEventContent MemberEvent { get; set; } [Parameter] public string? UserId { get; set; } [Parameter] public string? ProfileAvatar { get; set; } = null; [Parameter] public string? ProfileName { get; set; } = null; [Parameter] public AuthenticatedHomeserverGeneric? HomeServer { get; set; } private static SemaphoreSlim _semaphoreSlim = new(128); protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); HomeServer ??= await MRUStorage.GetCurrentSessionOrNavigate(); if(HomeServer is null) return; await _semaphoreSlim.WaitAsync(); if (User == null && UserId == null && MemberEvent != null) throw new ArgumentNullException(nameof(UserId)); if (MemberEvent != null) { User = new ProfileResponseEventContent { AvatarUrl = MemberEvent.AvatarUrl, DisplayName = MemberEvent.DisplayName }; } if (User is null && UserId is not null) { User ??= await HomeServer.GetProfileAsync(UserId); } ProfileAvatar ??= await hsResolver.ResolveMediaUri(HomeServer.FullHomeServerDomain, User.AvatarUrl); ProfileName ??= User.DisplayName; _semaphoreSlim.Release(); } }