blob: daa9c9eedb3c22518e02356e4ab1829af2641a6f (
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 LibMatrix.Helpers
@using LibMatrix.EventTypes.Spec.State
@using LibMatrix.Homeservers
@using LibMatrix.Responses
@using ArcaneLibs
<div style="background-color: #ffffff11; border-radius: 25px; margin: 8px; width: fit-Content;">
<img style="@(ChildContent is not null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@(string.IsNullOrWhiteSpace(User?.AvatarUrl) ? _identiconGenerator.GenerateAsDataUri(UserId) : User.AvatarUrl)"/>
<span style="vertical-align: middle; margin-right: 8px; border-radius: 75px;">@User?.DisplayName</span>
<div style="display: inline-block;">
@if (ChildContent is not null) {
@ChildContent
}
</div>
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public UserProfileResponse? User { get; set; }
[Parameter]
public string UserId { get; set; }
private AuthenticatedHomeserverGeneric _homeserver = null!;
private SvgIdenticonGenerator _identiconGenerator = new();
protected override async Task OnInitializedAsync() {
_homeserver = await RMUStorage.GetCurrentSessionOrNavigate();
if (_homeserver is null) return;
if (User == null) {
if (UserId == null) {
throw new ArgumentNullException(nameof(UserId));
}
User = await _homeserver.GetProfileAsync(UserId);
}
await base.OnInitializedAsync();
}
}
|