@using MatrixRoomUtils.Core.Responses
@profileName
@if (ChildContent != null)
{
@ChildContent
}
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public ProfileResponse 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(128);
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
await _semaphoreSlim.WaitAsync();
var hs = await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.UserId, RuntimeCache.CurrentHomeServer.AccessToken, RuntimeCache.CurrentHomeServer.HomeServerDomain).Configure();
if (User == null)
{
if (UserId == null)
{
throw new ArgumentNullException(nameof(UserId));
}
User = await hs.GetProfile(UserId);
}
else
{
// UserId = User.;
}
profileAvatar = RuntimeCache.CurrentHomeServer.ResolveMediaUri(User.AvatarUrl);
profileName = User.DisplayName;
_semaphoreSlim.Release();
if (Random.Shared.Next(100) == 1)
await LocalStorageWrapper.SaveCacheToLocalStorage(LocalStorage);
}
}