blob: 7a55380566ce1b762799d8dd9bf2a60ca6ccf66a (
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
|
@using LibMatrix.StateEventTypes
@using LibMatrix.StateEventTypes.Spec
@using LibMatrix.Helpers
<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="@profileAvatar"/>
<span style="vertical-align: middle; margin-right: 8px; border-radius: 75px;">@profileName</span>
<div style="display: inline-block;">
@if (ChildContent is not null) {
@ChildContent
}
</div>
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public ProfileResponseEventContent User { get; set; }
[Parameter]
public string UserId { get; set; }
private string? profileAvatar { get; set; } = "/icon-192.png";
private string? profileName { get; set; } = "Loading...";
private static SemaphoreSlim _semaphoreSlim = new(8);
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
var hs = await MRUStorage.GetCurrentSessionOrNavigate();
if (hs is null) return;
await _semaphoreSlim.WaitAsync();
if (User == null) {
if (UserId == null) {
throw new ArgumentNullException(nameof(UserId));
}
User = await hs.GetProfile(UserId);
}
// UserId = User.;
profileAvatar = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, User.AvatarUrl);
profileName = User.DisplayName;
_semaphoreSlim.Release();
}
}
|