about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-13 01:49:10 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-13 01:49:10 +0200
commitfc749b3e57098740377e6eabd5d010d133256fa5 (patch)
treecc97267a3d4222c910769e46bdb37c96c7c31531 /MatrixRoomUtils.Web/Shared/InlineUserItem.razor
parentunknown changes (diff)
downloadMatrixUtils-fc749b3e57098740377e6eabd5d010d133256fa5.tar.xz
Improved many features
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/InlineUserItem.razor')
-rw-r--r--MatrixRoomUtils.Web/Shared/InlineUserItem.razor63
1 files changed, 63 insertions, 0 deletions
diff --git a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
new file mode 100644
index 0000000..56131c8
--- /dev/null
+++ b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor
@@ -0,0 +1,63 @@
+@using MatrixRoomUtils.Core.Responses
+<div style="background-color: #ffffff11; border-radius: 0.5em; height: 1em; display: inline-block; vertical-align: middle;" alt="@UserId">
+    <img style="@(ChildContent != 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 != 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();
+        await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
+
+        await _semaphoreSlim.WaitAsync();
+
+        var hs = await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.UserId, RuntimeCache.CurrentHomeServer.AccessToken, RuntimeCache.CurrentHomeServer.HomeServerDomain).Configure();
+
+        if (User == null)
+        {
+            if (UserId == null)
+            {
+                throw new ArgumentNullException(nameof(UserId));
+            }
+            User = await hs.GetProfile(UserId);
+        }
+        else
+        {
+            // UserId = User.;
+        }
+        
+        ProfileAvatar ??= RuntimeCache.CurrentHomeServer.ResolveMediaUri(User.AvatarUrl);
+        ProfileName ??= User.DisplayName;
+
+        _semaphoreSlim.Release();
+    }
+
+}
\ No newline at end of file