diff --git a/Hushian.Application/Services/ChatService.cs b/Hushian.Application/Services/ChatService.cs index dcc03df..f09c5db 100644 --- a/Hushian.Application/Services/ChatService.cs +++ b/Hushian.Application/Services/ChatService.cs @@ -212,6 +212,8 @@ namespace Hushian.Application.Services }).FirstOrDefaultAsync(); Response.Success = mi.ID > 0; + if (Response.Success) + await NewChatInHub(dto.CompanyID); } else Response.Errors.Add("شناسه گروه صحیح نمی باشد"); @@ -508,6 +510,11 @@ namespace Hushian.Application.Services await _hubContext.Clients.User(UserID.ToString()) .SendAsync("CheckMarkAsRead", item); } + public async Task NewChatInHub(int CompanyID) + { + await _hubContext.Clients.All + .SendAsync("NewChat", CompanyID); + } } } diff --git a/Presentation/HushianWebApp/Pages/Chat.razor b/Presentation/HushianWebApp/Pages/Chat.razor index 20b44bb..fc30509 100644 --- a/Presentation/HushianWebApp/Pages/Chat.razor +++ b/Presentation/HushianWebApp/Pages/Chat.razor @@ -338,6 +338,12 @@ { ChatCurrent.Responses.First(a => a.ID == chatresponseid).IsRead = true; StateHasChanged(); } }); + //NewChat + hubConnection.On("NewChat", async (companyid) => + { + if (CurrentUser.CompanyID==companyid) + { Inbox1Items = await chatService.ChatAwaitingOurResponse(); StateHasChanged(); } + }); await hubConnection.StartAsync(); //---------end hub