2025-11-11 01:10:05 -06:00
|
|
|
@using LANCommander.SDK.Models
|
2025-09-24 20:58:23 -05:00
|
|
|
@using LANCommander.SDK.Services
|
2025-12-23 21:12:06 -06:00
|
|
|
@inject IChatClient ChatClient
|
2025-11-10 18:07:33 -06:00
|
|
|
@inject ModalService ModalService
|
2025-09-06 13:09:47 -05:00
|
|
|
@namespace LANCommander.UI.Components
|
2025-08-21 17:47:30 -05:00
|
|
|
|
2026-01-02 02:10:42 -06:00
|
|
|
<Flex Class="chat">
|
|
|
|
|
<Flex Direction="FlexDirection.Vertical" Class="chat-list">
|
|
|
|
|
<Button OnClick="StartThread">New Thread</Button>
|
|
|
|
|
|
|
|
|
|
<Divider />
|
|
|
|
|
|
|
|
|
|
<ChatList Threads="_threads" @bind-SelectedThread="_thread"/>
|
|
|
|
|
</Flex>
|
|
|
|
|
|
|
|
|
|
<ChatThread Id="_thread?.Id" />
|
|
|
|
|
</Flex>
|
2025-08-21 17:47:30 -05:00
|
|
|
|
|
|
|
|
@code {
|
2025-11-03 23:27:05 -06:00
|
|
|
IEnumerable<SDK.Models.ChatThread> _threads = [];
|
2025-12-30 18:08:20 -06:00
|
|
|
SDK.Models.ChatThread? _thread;
|
2025-08-21 17:47:30 -05:00
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
2025-09-24 20:58:23 -05:00
|
|
|
_threads = await ChatClient.GetThreadsAsync();
|
2025-08-21 17:47:30 -05:00
|
|
|
}
|
2025-08-24 19:34:14 -05:00
|
|
|
|
|
|
|
|
async Task StartThread()
|
|
|
|
|
{
|
2025-11-11 01:10:05 -06:00
|
|
|
var users = await ChatClient.GetUsersAsync();
|
|
|
|
|
|
|
|
|
|
var modalOptions = new ModalOptions
|
2025-11-10 18:07:33 -06:00
|
|
|
{
|
2025-11-11 01:10:05 -06:00
|
|
|
Draggable = false,
|
|
|
|
|
Centered = true,
|
|
|
|
|
Title = "New Thread",
|
|
|
|
|
};
|
2025-08-24 19:34:14 -05:00
|
|
|
|
2025-11-13 18:18:03 -06:00
|
|
|
var modalRef = ModalService.CreateModal<ChatUsersDialog, IEnumerable<User>, IEnumerable<User>>(modalOptions, users);
|
2025-11-11 01:10:05 -06:00
|
|
|
|
|
|
|
|
modalRef.OnOk = async (users) =>
|
|
|
|
|
{
|
2025-12-30 18:08:20 -06:00
|
|
|
var threadId = await ChatClient.StartThreadAsync(users.Select(u => u.Id.ToString()));
|
|
|
|
|
|
|
|
|
|
_thread = await ChatClient.GetThreadAsync(threadId);
|
2025-11-11 01:10:05 -06:00
|
|
|
_threads = await ChatClient.GetThreadsAsync();
|
|
|
|
|
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
};
|
2025-08-24 19:34:14 -05:00
|
|
|
}
|
2025-08-21 17:47:30 -05:00
|
|
|
}
|