diff --git a/Presentation/HushianWebApp/Pages/FromUserSide/AIChat.razor b/Presentation/HushianWebApp/Pages/FromUserSide/AIChat.razor index c19852f..0e7713a 100644 --- a/Presentation/HushianWebApp/Pages/FromUserSide/AIChat.razor +++ b/Presentation/HushianWebApp/Pages/FromUserSide/AIChat.razor @@ -19,63 +19,80 @@ } else -{ +{ گفتگو با دستیار هوشمند @CompanyInfo.FullName }
@if (isReady) { -
-
-

دستیار هوشمند @CompanyInfo.FullName

+
+
+

دستیار هوشمند @CompanyInfo.FullName

-
+
- -
-
-
- @if (messages is not null) - { -
- @foreach (var msg in messages) - { -
-
- @msg.requestText -
-
- -
-
- @msg.responseText -
-
- - } -
- } -
-
-
- - -
+
- +
+ @if (messages is not null) + { +
+ @foreach (var msg in messages) + { +
+
+ @msg.requestText +
+
+ +
+ + @if (msg.responseText=="null" && msg.dateTime==new DateTime(1400,01,01)) + { + + } + else{ +
+ @if (DelayShowResponse && messages.Last()==msg) + { + + } + else + { + @msg.responseText + } + +
+ } + + +
+ + } +
+ } +
+
+
+ + +
+
+
+ } else { @@ -98,29 +115,30 @@ else
@code { + public bool DelayShowResponse { get; set; } = false; ReadANDUpdate_CompanyDto? CompanyInfo = new(); [Parameter] public int CompanyID { get; set; } List messages = new(); string inputText = string.Empty; bool isReady = false; - bool isError= false; - string msgError= ""; + bool isError = false; + string msgError = ""; public string aikeyUser { get; set; } = ""; protected override async Task OnInitializedAsync() { await EnsureAuth(); - - CompanyInfo = await companyService.GetCompany(CompanyID); - if (CompanyInfo != null && CompanyInfo.allowBot) - { - await LoadMessages(); - isReady = true; - } - else - { - isError = true; - msgError = "دستیار هوشمند یافت نشد"; - } + + CompanyInfo = await companyService.GetCompany(CompanyID); + if (CompanyInfo != null && CompanyInfo.allowBot) + { + await LoadMessages(); + isReady = true; + } + else + { + isError = true; + msgError = "دستیار هوشمند یافت نشد"; + } } private async Task EnsureAuth() @@ -146,10 +164,23 @@ else if (string.IsNullOrWhiteSpace(inputText)) return; disSend = true; var dto = new aiNewResponseDto { companyId = CompanyID, aiKeyUser = aikeyUser, requestText = inputText }; + + + + var waiting = new aiResponseDto() + { + requestText = inputText, + responseText = "null", + dateTime = new(1400, 01, 01) + }; + messages.Add(waiting); + await JS.InvokeVoidAsync("scrollToBottom", "ai-chat"); var okmodel = await conversationService.AiNewResponse(dto); if (okmodel != null) { + DelayShowResponse = true; messages.Add(okmodel); + inputText = string.Empty; StateHasChanged(); await JS.InvokeVoidAsync("scrollToBottom", "ai-chat"); @@ -158,6 +189,7 @@ else { toastService.Notify(new ToastMessage(ToastType.Danger, "ارسال ناموفق بود")); } + messages.Remove(waiting); disSend = false; } @@ -287,7 +319,6 @@ else -webkit-text-fill-color: transparent; background-clip: text; } -