@using System.Collections.Specialized @using LANCommander.SDK @using LANCommander.SDK.Services @using Microsoft.AspNetCore.Components.Web.Virtualization @inject ChatClient ChatClient @namespace LANCommander.UI.Components
@code { [Parameter] public Guid Id { get; set; } ICollection _messageGroups; ICollection _messages = new List(); SDK.Models.ChatThread _thread; bool _sendingMessage = false; string _inputContents = String.Empty; protected override async Task OnParametersSetAsync() { if (Id != Guid.Empty) { _thread = ChatClient.GetThread(Id); _thread.MessageGroups.CollectionChanged += MessageGroupsOnCollectionChanged; } } void MessageGroupsOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { StateHasChanged(); } async Task SendMessage(PressEnterEventArgs args) { if (!args.ShiftKey) { _sendingMessage = true; await ChatClient.SendMessageAsync(Id, _inputContents); } } }