blob: 08161b24aec3c51b18214b5d4d5dab506e1b4eee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
@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
<div style="margin-bottom: 1em;">
<img style="border-radius: 50%; height: 3em; width: 3em;" src="@_avatarUrl"/>
<span style="margin-left: 1em;"><input type="radio" name="csa" checked="@(RuntimeCache.LastUsedToken == User.AccessToken)" onclick="@SetCurrent" style="text-decoration-line: unset;"/> <b>@User.Profile.DisplayName</b> on <b>@User.LoginResponse.HomeServer</b></span>
<a href="#" onclick="@RemoveUser">Remove</a>
</div>
@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();
}
}
|