blob: fd2fdec2067fc8084183376765b315772e6ae7b5 (
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
51
52
53
54
55
56
57
58
|
@using LibMatrix.Responses
@using ArcaneLibs
<div style="background-color: #ffffff11; border-radius: 25px; margin: 8px; width: fit-Content;">
@if (!string.IsNullOrWhiteSpace(User?.AvatarUrl)) {
<MxcAvatar Homeserver="@_homeserver" Size="32" Circular="true" MxcUri="@User.AvatarUrl"/>
}
else {
<img style="@(ChildContent is not null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@_identiconGenerator.GenerateAsDataUri(UserId)"/>
}
<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; }
[Parameter]
public AuthenticatedHomeserverGeneric _homeserver { get; set; }
private static SvgIdenticonGenerator _identiconGenerator = new();
protected override async Task OnInitializedAsync() {
// _homeserver = await sessionStore.GetCurrentHomeserver(navigateOnFailure: true);
// if (_homeserver is null) return;
if (User == null) {
if (UserId == null) {
throw new ArgumentNullException(nameof(UserId));
}
try {
User = await _homeserver.GetProfileAsync(UserId);
}
catch (Exception) {
User = new() {
DisplayName = UserId
};
}
}
await base.OnInitializedAsync();
}
}
|