This commit is contained in:
mmrbnjd
2025-08-23 22:55:37 +03:30
parent e964cb551e
commit ca46987be9
3 changed files with 49 additions and 21 deletions

View File

@@ -285,20 +285,25 @@ namespace Hushian.Application.Services
await WriteInHubFromCompany(Response.Value, convModel.UserID.ToString());
else
{
List<string> users = new();
users.Add("C" + convModel.CompanyID.ToString());
var modelA = convModel.ConversationResponses.OrderBy(o => o.ID)
.LastOrDefault(l =>/* l.Type == ConversationType.EU || l.Type == ConversationType.CU*/ l.ExperID.HasValue);
if (modelA != null)
{
string user ="";
if (modelA != null /*&& (modelA.Type == ConversationType.EU || modelA.Type == ConversationType.UE)*/)
// {
if (modelA.Type == ConversationType.EU || modelA.Type == ConversationType.UE) user = modelA.ExperID.Value.ToString();
//if ()
users.Add(modelA.ExperID.Value.ToString());
else if (modelA.Type == ConversationType.CU) user ="C"+ modelA.conversation.CompanyID.ToString();
await WriteInHubFromUser(Response.Value, user);
}
else await NewChatInHub(convModel.CompanyID);
// }
//else await NewChatInHub(convModel.CompanyID);
await WriteInHubFromUser(Response.Value, users);
}
}
@@ -502,8 +507,9 @@ namespace Hushian.Application.Services
// // .SendAsync("ReceiveNewConversation", conv.Id, conv.Title);
//}
}
public async Task WriteInHubFromUser(ChatItemResponseDto item, string ToUser)
public async Task WriteInHubFromUser(ChatItemResponseDto item,List< string> ToUserS)
{
foreach (var ToUser in ToUserS)
await _hubContext.Clients.User(ToUser)
.SendAsync("ReceiveNewChatItemFromUser", item);
}

View File

@@ -118,9 +118,9 @@
}
else
{
<Icon Name="IconName.ArrowBarUp" Size="IconSize.x5" Style="height=10px;width=10px" />
<Icon Name="IconName.ArrowBarUp" Size="IconSize.x5" Style="height=10px;width=10px" />
}
@item.LastText
</div>
</div>
@@ -166,9 +166,11 @@
<!-- Main Chat Section (B) -->
<div class="col-md-9 d-flex flex-column" id="B">
<div class="input-group">
@if (ChatCurrent != null)
{
<small>@ChatCurrent?.ID)</small>
<p type="text" class="form-control fw-bold text-primary" style="border:none;align-self: center;" aria-describedby="basic-addon1">@SelectedChatUserName</p>
<div class="d-flex gap-2 ms-auto">
@if (ChatCurrent.status == Common.Enums.ConversationStatus.InProgress)
@@ -373,7 +375,7 @@
@code {
Common.Dtos.CurrentUserInfo CurrentUser { get; set; }
List<Read_GroupDto> _Group = new List<Read_GroupDto>();
//-------------------------------------
@@ -386,7 +388,7 @@
/////////////
ChatItemDto? ChatCurrent { get; set; } = null;
string MsgInput { get; set; }
IBrowserFile? SelectedImageFile = null;
IBrowserFile? SelectedImageFile = null;
byte[]? SelectedImageBytes = null;
string? SelectedImagePreview = null;
@@ -400,7 +402,7 @@
private DateTime recordingStartTime;
bool chatloading = false;
string SelectedChatUserName = "مهدی ربیع نژاد";
string SelectedChatUserName = "";
private bool _shouldObserveVisibility = false;
private ConfirmDialog dialog = default!;
private Modal modal = default!;
@@ -453,7 +455,7 @@
//NewChat
hubConnection.On<int>("NewChat", async (companyid) =>
{
if (CurrentUser.CompanyID==companyid)
if (CurrentUser.CompanyID==companyid)
{ Inbox1Items = await chatService.ChatAwaitingOurResponse(); StateHasChanged(); }
});
await hubConnection.StartAsync();
@@ -555,7 +557,21 @@
{
chatloading = true;
SelectedChatUserName = "در حال گفتگو با " + chatItem.UserFullName;
SelectedChatUserName = "در حال گفتگو با '" + chatItem.UserFullName + "'";
if (CurrentUser.Role == "Company")
{
var mo = chatItem.Responses.OrderBy(o => o.ID).Last(l => l.Type != ConversationType.UE);
if (mo!=null && mo.Type == Common.Enums.ConversationType.EU)
SelectedChatUserName = "گفتگوی '" + mo.ExperName + "' با '" + chatItem.UserFullName+"'";
}
ChatCurrent = chatItem;
_shouldObserveVisibility = true; // فعال کن تا در OnAfterRenderAsync صدا زده بشه

View File

@@ -7,10 +7,13 @@
@using HushianWebApp.Services
@using Microsoft.AspNetCore.SignalR.Client;
@using System.Threading;
@if(CompanyInfo!=null)
<PageTitle>به هوشیان خوش آمدید</PageTitle>
@if (CompanyInfo != null && !string.IsNullOrEmpty(CompanyInfo?.FullName))
{
<PageTitle>گفتگو با @CompanyInfo?.FullName</PageTitle>
}
@inject NavigationManager NavigationManager
@inject ChatService ChatService
@inject ILocalStorageService localStorageService;
@@ -41,7 +44,7 @@
<div class="d-flex gap-2 ms-auto">
@if (LastOpenChat != null)
{
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" @onclick="NewChat" Class="new-conversation-btn">
<Icon Name="IconName.ChatDots" Class="me-1" /> گفتگو جدید
</Button>
@@ -170,7 +173,7 @@
<Button Color="ButtonColor.Secondary" Size=ButtonSize.Small Outline="true" @onclick="OpenFileDialog" Class="attach-btn" title="افزودن تصویر">
<Icon Name="IconName.Image" />
</Button>
<!-- Audio Recording Button -->
<Button Color="@(IsRecording ? ButtonColor.Danger : ButtonColor.Secondary)"
Size=ButtonSize.Small
@@ -230,7 +233,7 @@
</div>
}
</div>
@if (LastOpenChat!=null && LastOpenChat.status == Common.Enums.ConversationStatus.InProgress)
{
@@ -240,7 +243,10 @@
}
}
@if (LastOpenChat.status == Common.Enums.ConversationStatus.Finished)
{
<p style="color: red;text-align: center;font-weight: bold;">این گفتگو به پایان رسیده</p>
}
</div>
}
else