@using LibMatrix.Helpers
@using LibMatrix.EventTypes.Spec.State
@profileName
@if (ChildContent is not null) {
@ChildContent
}
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public ProfileResponseEventContent User { get; set; }
[Parameter]
public string UserId { get; set; }
private string? profileAvatar { get; set; } = "/icon-192.png";
private string? profileName { get; set; } = "Loading...";
private static SemaphoreSlim _semaphoreSlim = new(8);
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
var hs = await MRUStorage.GetCurrentSessionOrNavigate();
if (hs is null) return;
await _semaphoreSlim.WaitAsync();
if (User == null) {
if (UserId == null) {
throw new ArgumentNullException(nameof(UserId));
}
User = await hs.GetProfileAsync(UserId);
}
// UserId = User.;
profileAvatar = await hsResolver.ResolveMediaUri(hs.ServerName, User.AvatarUrl);
profileName = User.DisplayName;
_semaphoreSlim.Release();
}
}