51 lines
No EOL
1.4 KiB
Text
51 lines
No EOL
1.4 KiB
Text
@using LANCommander.SDK.Models
|
|
@using LANCommander.SDK.Services
|
|
@inject IChatClient ChatClient
|
|
@inject ModalService ModalService
|
|
@namespace LANCommander.UI.Components
|
|
|
|
<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>
|
|
|
|
@code {
|
|
IEnumerable<SDK.Models.ChatThread> _threads = [];
|
|
SDK.Models.ChatThread? _thread;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_threads = await ChatClient.GetThreadsAsync();
|
|
}
|
|
|
|
async Task StartThread()
|
|
{
|
|
var users = await ChatClient.GetUsersAsync();
|
|
|
|
var modalOptions = new ModalOptions
|
|
{
|
|
Draggable = false,
|
|
Centered = true,
|
|
Title = "New Thread",
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<ChatUsersDialog, IEnumerable<User>, IEnumerable<User>>(modalOptions, users);
|
|
|
|
modalRef.OnOk = async (users) =>
|
|
{
|
|
var threadId = await ChatClient.StartThreadAsync(users.Select(u => u.Id.ToString()));
|
|
|
|
_thread = await ChatClient.GetThreadAsync(threadId);
|
|
_threads = await ChatClient.GetThreadsAsync();
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
};
|
|
}
|
|
} |