...
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
@inject ChatService chatService
|
||||
@inject IJSRuntime JS
|
||||
@inject ToastService toastService
|
||||
@inject HttpClient _Http;
|
||||
@layout UserPanelLayout
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
|
||||
@@ -262,14 +263,14 @@
|
||||
}
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Console.WriteLine($"🔔 welcome");
|
||||
|
||||
await IsOnline();
|
||||
//-------------hub
|
||||
var token = await localStorageService.GetItem<string>("U/key");
|
||||
string AddressHub = _Http.BaseAddress.AbsoluteUri.Replace("api/", "");
|
||||
|
||||
hubConnection = new HubConnectionBuilder()
|
||||
.WithUrl("http://localhost:5089/chatNotificationHub", options =>
|
||||
.WithUrl($"{AddressHub}chatNotificationHub", options =>
|
||||
{
|
||||
options.AccessTokenProvider = () => Task.FromResult(token);
|
||||
})
|
||||
@@ -282,11 +283,20 @@
|
||||
{
|
||||
LastOpenChat.Responses.Add(chatitem);
|
||||
StateHasChanged();
|
||||
await MarkAsRead(chatitem.ID);
|
||||
await MarkAsRead(chatitem.ID);
|
||||
// Scroll to target if exists, otherwise scroll to bottom
|
||||
await JS.InvokeVoidAsync("scrollToTargetOrBottom");
|
||||
}
|
||||
});
|
||||
//-------------------------------------
|
||||
hubConnection.On<int>("CheckMarkAsRead", async (chatresponseid) =>
|
||||
{
|
||||
if (LastOpenChat.Responses.Any(a=>a.ID==chatresponseid && !a.IsRead && a.Type==Common.Enums.ConversationType.UE))
|
||||
{
|
||||
LastOpenChat.Responses.First(a => a.ID == chatresponseid).IsRead = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
});
|
||||
|
||||
await hubConnection.StartAsync();
|
||||
//---------end hub
|
||||
|
Reference in New Issue
Block a user