- Load thread after creation - Change thread list from DataList to Flex - Move unread badge to right side of chat thread list item - Fix avatar rerendering after another message is added to message group - Add styling to thread list - Change message input to support markdown and add markdown rendering for message contents
57 lines
No EOL
1.8 KiB
Text
57 lines
No EOL
1.8 KiB
Text
@using LANCommander.SDK.Services
|
|
@namespace LANCommander.UI.Components
|
|
@inject IChatClient ChatClient
|
|
|
|
<MouseArea Cursor="Cursors.Pointer" OnClick="OnClick" Class="@_cssClass">
|
|
<Flex Align="FlexAlign.Center" Gap="FlexGap.Small">
|
|
<div class="chat-list-thread-avatar">
|
|
@if (Thread.Participants.Count == 2)
|
|
{
|
|
<SafeAvatar
|
|
Shape="AvatarShape.Square"
|
|
Size="AvatarSize.Large"
|
|
Username="@Thread.Participants.First().Name" />
|
|
}
|
|
else
|
|
{
|
|
<SafeAvatarGroup
|
|
Shape="AvatarShape.Square"
|
|
Size="AvatarSize.Large"
|
|
Usernames="@Thread.Participants.Select(p => p.Name)" />
|
|
}
|
|
</div>
|
|
|
|
<div class="chat-list-thread-title">
|
|
@Thread.Title
|
|
</div>
|
|
|
|
<div class="chat-list-thread-unread">
|
|
<Badge Count="_unreadCount" OverflowCount="99" />
|
|
</div>
|
|
</Flex>
|
|
</MouseArea>
|
|
|
|
@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 _cssClass = string.Empty;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
_unreadCount = await ChatClient.GetUnreadMessageCountAsync(Thread.Id);
|
|
|
|
_cssClass = new ClassBuilder()
|
|
.Add("chat-list-thread")
|
|
.If(() => Active, "chat-list-thread-active")
|
|
.Build();
|
|
}
|
|
|
|
async Task OnClick(MouseEventArgs args)
|
|
{
|
|
if (OnSelected.HasDelegate)
|
|
await OnSelected.InvokeAsync(Thread);
|
|
}
|
|
} |