@using MatrixRoomUtils.Web.Classes
@using System.Text.Json
@using Blazored.LocalStorage
@using MatrixRoomUtils.Core
@using MatrixRoomUtils.Core.Extensions
@using Index = MatrixRoomUtils.Web.Pages.Index
@using System.ComponentModel.DataAnnotations
@inject ILocalStorageService LocalStorage
@inject NavigationManager NavigationManager
@code {
[Parameter]
public UserInfo User { get; set; } = null!;
private string _avatarUrl { get; set; }
protected override async Task OnInitializedAsync()
{
if (User.Profile.AvatarUrl != null && User.Profile.AvatarUrl != "")
_avatarUrl = await (await new AuthenticatedHomeServer(User.LoginResponse.UserId, User.AccessToken, User.LoginResponse.HomeServer).Configure()).ResolveMediaUri(User.Profile.AvatarUrl);
else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId;
await base.OnInitializedAsync();
}
private async Task RemoveUser()
{
Console.WriteLine(User.ToJson());
RuntimeCache.LoginSessions.Remove(User.AccessToken);
await LocalStorageWrapper.ReloadLocalStorage(LocalStorage);
StateHasChanged();
}
private async Task SetCurrent()
{
RuntimeCache.LastUsedToken = User.AccessToken;
//RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer);
await LocalStorageWrapper.ReloadLocalStorage(LocalStorage);
StateHasChanged();
}
}