@using MatrixRoomUtils.Core.Extensions
@inject ILocalStorageService LocalStorage
@inject NavigationManager NavigationManager
@code {
[Parameter]
public UserInfo User { get; set; } = null!;
private string? _avatarUrl { get; set; }
private int _roomCount { get; set; } = 0;
protected override async Task OnInitializedAsync() {
await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
if (User.Profile.AvatarUrl != null && User.Profile.AvatarUrl != "")
_avatarUrl = RuntimeCache.CurrentHomeServer.ResolveMediaUri(User.Profile.AvatarUrl);
else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId;
try {
_roomCount = (await RuntimeCache.CurrentHomeServer.GetJoinedRooms()).Count;
}
catch {
_roomCount = -1;
}
await base.OnInitializedAsync();
}
private async Task RemoveUser() {
Console.WriteLine(User.ToJson());
RuntimeCache.LoginSessions.Remove(User.AccessToken);
StateHasChanged();
}
private async Task SetCurrent() {
RuntimeCache.LastUsedToken = User.AccessToken;
//RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer);
await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
await LocalStorageWrapper.InitialiseRuntimeVariables(LocalStorage);
StateHasChanged();
}
}