diff --git a/Hushian.Application/Services/ChatService.cs b/Hushian.Application/Services/ChatService.cs index 47f5ea2..73666e7 100644 --- a/Hushian.Application/Services/ChatService.cs +++ b/Hushian.Application/Services/ChatService.cs @@ -285,20 +285,25 @@ namespace Hushian.Application.Services await WriteInHubFromCompany(Response.Value, convModel.UserID.ToString()); else { + List 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); } diff --git a/Presentation/HushianWebApp/Pages/Chat.razor b/Presentation/HushianWebApp/Pages/Chat.razor index 651945b..794cdd3 100644 --- a/Presentation/HushianWebApp/Pages/Chat.razor +++ b/Presentation/HushianWebApp/Pages/Chat.razor @@ -118,9 +118,9 @@ } else { - + } - + @item.LastText @@ -166,9 +166,11 @@
+
@if (ChatCurrent != null) { + @ChatCurrent?.ID)

@SelectedChatUserName

@if (ChatCurrent.status == Common.Enums.ConversationStatus.InProgress) @@ -373,7 +375,7 @@ @code { - + Common.Dtos.CurrentUserInfo CurrentUser { get; set; } List _Group = new List(); //------------------------------------- @@ -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("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 صدا زده بشه diff --git a/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor b/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor index b6f6987..13c6605 100644 --- a/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor +++ b/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor @@ -7,10 +7,13 @@ @using HushianWebApp.Services @using Microsoft.AspNetCore.SignalR.Client; @using System.Threading; -@if(CompanyInfo!=null) +به هوشیان خوش آمدید + +@if (CompanyInfo != null && !string.IsNullOrEmpty(CompanyInfo?.FullName)) { گفتگو با @CompanyInfo?.FullName } + @inject NavigationManager NavigationManager @inject ChatService ChatService @inject ILocalStorageService localStorageService; @@ -41,7 +44,7 @@
@if (LastOpenChat != null) { - + @@ -170,7 +173,7 @@ - +
@if (LastOpenChat!=null && LastOpenChat.status == Common.Enums.ConversationStatus.InProgress) { @@ -240,7 +243,10 @@ } } - + @if (LastOpenChat.status == Common.Enums.ConversationStatus.Finished) + { +

این گفتگو به پایان رسیده

+ }
} else