...
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
@inject GroupService groupService
|
||||
@inject ChatService chatService
|
||||
@inject IJSRuntime JS
|
||||
@inject ToastService toastService
|
||||
@layout UserPanelLayout
|
||||
<div class="container-fluid">
|
||||
<div class="row" style="height:85vh">
|
||||
@@ -138,7 +139,7 @@
|
||||
@code {
|
||||
[Parameter] public int CompanyID { get; set; }
|
||||
private bool _shouldObserveVisibility = false;
|
||||
|
||||
int? GroupID = null;
|
||||
ReadANDUpdate_CompanyDto? CompanyInfo = new();
|
||||
Common.Dtos.CurrentUserInfo CurrentUser = new();
|
||||
List<Read_GroupDto> CompanyGroups = new();
|
||||
@@ -172,15 +173,26 @@
|
||||
var model = await chatService.ADDChatResponse(LastOpenChat.ID, MsgInput, type);
|
||||
LastOpenChat?.Responses.Add(model);
|
||||
LastOpenChat.LastText = MsgInput;
|
||||
await Task.Yield();
|
||||
// Scroll to bottom for user's own messages
|
||||
await JS.InvokeVoidAsync("scrollToBottom", "B1");
|
||||
MsgInput = string.Empty;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO New Chat
|
||||
var model = await chatService.NewChatFromCurrentUser(new ADD_ConversationDto()
|
||||
{
|
||||
CompanyID = CompanyID,
|
||||
GroupID = GroupID,
|
||||
Question = MsgInput,
|
||||
UserID = 0
|
||||
});
|
||||
if (model != null) LastOpenChat = model;
|
||||
else toastService.Notify(new ToastMessage(ToastType.Danger, "خطا در گفتگو جدید"));
|
||||
|
||||
}
|
||||
await Task.Yield();
|
||||
// Scroll to bottom for user's own messages
|
||||
await JS.InvokeVoidAsync("scrollToBottom", "B1");
|
||||
MsgInput = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -245,14 +257,14 @@
|
||||
LastOpenChat = null;
|
||||
if (LastOpenChat != null)
|
||||
{
|
||||
|
||||
|
||||
// Always set up visibility observation for chat bubbles
|
||||
_shouldObserveVisibility = true;
|
||||
StateHasChanged();
|
||||
|
||||
|
||||
// Wait for render to complete
|
||||
await Task.Delay(200);
|
||||
|
||||
|
||||
// Scroll to target if exists, otherwise scroll to bottom
|
||||
await JS.InvokeVoidAsync("scrollToTargetOrBottom");
|
||||
}
|
||||
@@ -266,7 +278,7 @@
|
||||
{
|
||||
msg.IsRead = true;
|
||||
await chatService.MarkAsReadChatItemAsync(id);
|
||||
// StateHasChanged();
|
||||
// StateHasChanged();
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
@@ -790,7 +802,7 @@
|
||||
const targetRect = targetElement.getBoundingClientRect();
|
||||
const containerRect = chatContainer.getBoundingClientRect();
|
||||
const relativeTop = targetRect.top - containerRect.top;
|
||||
|
||||
|
||||
// Scroll to show the target element with some padding
|
||||
const scrollPosition = chatContainer.scrollTop + relativeTop - 100; // 100px padding
|
||||
chatContainer.scrollTo({
|
||||
|
Reference in New Issue
Block a user