@using MatrixRoomUtils.Core.Responses
@using MatrixRoomUtils.Core.StateEventTypes
@using MatrixRoomUtils.Core.Helpers
@using MatrixRoomUtils.Core.StateEventTypes.Spec
@profileName
@if (ChildContent is not null) {
@ChildContent
}
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public ProfileResponseEventData 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.GetProfile(UserId);
}
// UserId = User.;
profileAvatar = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, User.AvatarUrl);
profileName = User.DisplayName;
_semaphoreSlim.Release();
}
}