blob: a498c70f1e95d227cb2b15bae83fa71045fddffd (
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
|
@using MatrixRoomUtils.Core.Responses
@using MatrixRoomUtils.Core.StateEventTypes
@using MatrixRoomUtils.Core.Helpers
<div style="background-color: #ffffff11; border-radius: 0.5em; height: 1em; display: inline-block; vertical-align: middle;" alt="@UserId">
<img style="@(ChildContent is not null ? "vertical-align: baseline;" : "vertical-align: top;") width: 1em; height: 1em; border-radius: 50%;" src="@ProfileAvatar"/>
<span style="position: relative; top: -5px;">@ProfileName</span>
<div style="display: inline-block;">
@if (ChildContent is not null) {
@ChildContent
}
</div>
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public ProfileResponse User { get; set; }
[Parameter]
public string? UserId { get; set; }
[Parameter]
public string? ProfileAvatar { get; set; } = null;
[Parameter]
public string? ProfileName { get; set; } = null;
private static SemaphoreSlim _semaphoreSlim = new(128);
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
var hs = await MRUStorage.GetCurrentSession();
await _semaphoreSlim.WaitAsync();
if (User == null && UserId == null)
throw new ArgumentNullException(nameof(UserId));
User ??= await hs.GetProfile(UserId);
ProfileAvatar ??= MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, User.AvatarUrl);
ProfileName ??= User.DisplayName;
_semaphoreSlim.Release();
}
}
|