53 lines
No EOL
1.6 KiB
Text
53 lines
No EOL
1.6 KiB
Text
@using LANCommander.SDK.Services
|
|
@namespace LANCommander.UI.Components
|
|
@inject RpcClient RpcClient
|
|
|
|
<div class="chat-list-thread @_class" @onclick="OnClick">
|
|
<div class="chat-list-thread-avatar">
|
|
@if (Thread.Participants.Count == 2)
|
|
{
|
|
<Badge Count="_unreadCount" OverflowCount="99">
|
|
<SafeAvatar
|
|
Shape="AvatarShape.Square"
|
|
Size="AvatarSize.Large"
|
|
Username="@Thread.Participants.First().Name" />
|
|
</Badge>
|
|
}
|
|
else
|
|
{
|
|
<Badge Count="_unreadCount" OverflowCount="99">
|
|
<SafeAvatarGroup
|
|
Shape="AvatarShape.Square"
|
|
Size="AvatarSize.Large"
|
|
Usernames="@Thread.Participants.Select(p => p.Name)" />
|
|
</Badge>
|
|
}
|
|
</div>
|
|
<div class="chat-list-thread-title">
|
|
@Thread.Title
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter] public required SDK.Models.ChatThread Thread { get; set; }
|
|
[Parameter] public EventCallback<SDK.Models.ChatThread> OnSelected { get; set; }
|
|
[Parameter] public bool Active { get; set; }
|
|
|
|
int _unreadCount = 0;
|
|
string _class = String.Empty;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
_unreadCount = await RpcClient.Chat.GetUnreadMessageCountAsync(Thread.Id);
|
|
|
|
_class = new ClassBuilder()
|
|
.If(() => Active, "chat-list-thread-active")
|
|
.Build();
|
|
}
|
|
|
|
async Task OnClick(MouseEventArgs args)
|
|
{
|
|
if (OnSelected.HasDelegate)
|
|
await OnSelected.InvokeAsync(Thread);
|
|
}
|
|
} |