...
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
@inject GroupService groupService
|
||||
@inject UserService userService
|
||||
@inject IJSRuntime JS
|
||||
@inject ToastService toastService
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
<PageTitle>گفتمان</PageTitle>
|
||||
<div class="container-fluid">
|
||||
<div class="row" style="height:85vh">
|
||||
@@ -64,11 +66,11 @@
|
||||
<Badge Color="BadgeColor.Info" VisuallyHiddenText="Visually hidden text for Info">@item.GroupName</Badge>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
<div class="item-time">
|
||||
<small class="time-text">@item.LastMsgdate</small>
|
||||
<small class="time-text">@item.LastMsgtime</small>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-message">@item.LastText</div>
|
||||
@@ -152,11 +154,7 @@
|
||||
@if (ChatCurrent.status == Common.Enums.ConversationStatus.InProgress)
|
||||
{
|
||||
<Button Color="ButtonColor.Danger" Size=ButtonSize.ExtraSmall Outline="true" Class="finish-conversation-btn"
|
||||
@onclick="async()=>
|
||||
{
|
||||
if(await chatService.ChatIsFinish(ChatCurrent.ID))
|
||||
ChatCurrent.status=Common.Enums.ConversationStatus.Finished;
|
||||
}">
|
||||
@onclick="CloseChat">
|
||||
<Icon Name="IconName.Escape" /> اتمام گفتگو
|
||||
</Button>
|
||||
|
||||
@@ -167,7 +165,8 @@
|
||||
else if (ChatCurrent.status == Common.Enums.ConversationStatus.Finished
|
||||
&& (CurrentUser.Role == "Company" || ChatCurrent.ExperID == CurrentUser.ExperID))
|
||||
{
|
||||
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" Class="finish-conversation-btn">
|
||||
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" Class="finish-conversation-btn"
|
||||
@onclick="OpenChat">
|
||||
|
||||
<Icon Name="IconName.Escape" /> باز کردن گفتگو
|
||||
</Button>
|
||||
@@ -283,7 +282,7 @@
|
||||
bool chatloading = false;
|
||||
string SelectedChatUserName = "مهدی ربیع نژاد";
|
||||
private bool _shouldObserveVisibility = false;
|
||||
|
||||
private ConfirmDialog dialog = default!;
|
||||
|
||||
}
|
||||
@functions {
|
||||
@@ -351,7 +350,7 @@
|
||||
chatloading = true;
|
||||
SelectedChatUserName = "در حال گفتگو با " + chatItem.UserFullName;
|
||||
ChatCurrent = chatItem;
|
||||
|
||||
|
||||
_shouldObserveVisibility = true; // فعال کن تا در OnAfterRenderAsync صدا زده بشه
|
||||
|
||||
StateHasChanged(); // مجبور کن Blazor رندر کنه
|
||||
@@ -367,8 +366,50 @@
|
||||
msg.IsRead = true;
|
||||
await chatService.MarkAsReadChatItemAsync(id);
|
||||
}
|
||||
// StateHasChanged();
|
||||
// StateHasChanged();
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
async Task OpenChat()
|
||||
{
|
||||
if (CurrentUser.Role == "Company" || CurrentUser.Role == "Exper" && ChatCurrent.ExperID==CurrentUser.ExperID)
|
||||
{
|
||||
if (ChatCurrent.status != Common.Enums.ConversationStatus.Finished) return;
|
||||
if (await chatService.OpenChat(ChatCurrent.ID))
|
||||
{
|
||||
ChatCurrent.status = Common.Enums.ConversationStatus.InProgress;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
else toastService.Notify(new ToastMessage(ToastType.Danger, "دسترسی به این گفتگو ندارید"));
|
||||
|
||||
}
|
||||
async Task CloseChat()
|
||||
{
|
||||
if (ChatCurrent.status == Common.Enums.ConversationStatus.Finished) return;
|
||||
var options = new ConfirmDialogOptions
|
||||
{
|
||||
YesButtonText = "بله",
|
||||
YesButtonColor = ButtonColor.Success,
|
||||
NoButtonText = "انصراف",
|
||||
NoButtonColor = ButtonColor.Danger
|
||||
};
|
||||
|
||||
var confirmation = await dialog.ShowAsync(
|
||||
title: "پایان دادن به گفتگو",
|
||||
message1: "اطمینان دارید ؟",
|
||||
confirmDialogOptions: options);
|
||||
|
||||
if (confirmation)
|
||||
{
|
||||
if (await chatService.ChatIsFinish(ChatCurrent.ID))
|
||||
{
|
||||
ChatCurrent.status = Common.Enums.ConversationStatus.Finished;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user