[frontend/components] Refactor NoteUserInfo

This commit is contained in:
pancakes 2024-11-05 16:57:25 +10:00
parent cfcccf7654
commit 3509d94309
No known key found for this signature in database
GPG key ID: ED53D426432B861B
2 changed files with 10 additions and 17 deletions

View file

@ -5,12 +5,7 @@
@inject ComposeService ComposeService
@inject SessionService Session;
<div class="note-header">
<NoteUserInfo
AvatarUrl="@Note.User.AvatarUrl"
DisplayName="@Note.User.DisplayName"
Username="@Note.User.Username"
Host="@Note.User.Host"
Indented="Indented"/>
<NoteUserInfo User="@Note.User" Indented="Indented"/>
<NoteMetadata
Visibility="@Note.Visibility"
InstanceName="@Note.User.InstanceName"

View file

@ -1,27 +1,25 @@
@using Iceshrimp.Shared.Schemas.Web
@inject NavigationManager Nav
@if (Indented == false)
{
<img @onclick="OpenProfile" class="user-avatar" src="@AvatarUrl" alt="@(DisplayName ?? Username)" role="link"/>
<img @onclick="OpenProfile" class="user-avatar" src="@(User.AvatarUrl ?? $"/identicon/{User.Id}")" alt="@(User.DisplayName ?? User.Username)" role="link"/>
}
<div class="name-section">
<span class="display-name">@(DisplayName ?? Username)</span>
<span class="identifier">@@@Username@(Host != null ? $"@{Host}" : "")</span>
<span class="display-name"><UserDisplayName User="@User"/></span>
<span class="identifier">@@@User.Username@(User.Host != null ? $"@{User.Host}" : "")</span>
</div>
@code {
[Parameter] [EditorRequired] public required string AvatarUrl { get; set; }
[Parameter] [EditorRequired] public required string? DisplayName { get; set; }
[Parameter] [EditorRequired] public required string Username { get; set; }
[Parameter] [EditorRequired] public required bool Indented { get; set; }
[Parameter] [EditorRequired] public required string? Host { get; set; }
[Parameter] [EditorRequired] public required UserResponse User { get; set; }
[Parameter] [EditorRequired] public required bool Indented { get; set; }
private void OpenProfile()
{
var path = $"@{Username}";
if (Host?.Length > 0)
var path = $"@{User.Username}";
if (User.Host?.Length > 0)
{
path += $"@{Host}";
path += $"@{User.Host}";
}
Nav.NavigateTo($"/{path}");