blob: 33054e5d77d983c913903750643bf0e07aa2c39d (
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
49
50
|
@using MatrixRoomUtils.Authentication
@using MatrixRoomUtils.Web.Classes
@using System.Text.Json
@using Blazored.LocalStorage
@using MatrixRoomUtils.Extensions
@using Index = MatrixRoomUtils.Web.Pages.Index
@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="@(LocalStorageWrapper.AccessToken == Token)" 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 string Token { get; set; }
[Parameter]
public UserInfo User { get; set; }
private string _avatarUrl { get; set; }
private bool _removed { get; set; } = false;
protected override async Task OnInitializedAsync()
{
if(User.Profile.AvatarUrl != null && User.Profile.AvatarUrl != "")
_avatarUrl = await User.Profile.AvatarUrl.GetMediaUrl();
else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId;
await base.OnInitializedAsync();
}
private async Task RemoveUser()
{
LocalStorageWrapper.LoginSessions.Remove(Token);
await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
_removed = true;
StateHasChanged();
}
private async Task SetCurrent()
{
LocalStorageWrapper.AccessToken = Token;
LocalStorageWrapper.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer);
await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
StateHasChanged();
}
}
|