...
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
@using Common.Dtos.Group
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ChatService ChatService
|
||||
@inject ILocalStorageService localStorageService;
|
||||
@inject AuthService authService;
|
||||
@@ -173,7 +176,7 @@
|
||||
[Parameter] public int CompanyID { get; set; }
|
||||
[Parameter] public int? ChatID { get; set; }
|
||||
private ConfirmDialog dialog = default!;
|
||||
|
||||
private HubConnection? hubConnection;
|
||||
private bool _shouldObserveVisibility = false;
|
||||
int? GroupID = null;
|
||||
ReadANDUpdate_CompanyDto? CompanyInfo = new();
|
||||
@@ -259,7 +262,34 @@
|
||||
}
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Console.WriteLine($"🔔 welcome");
|
||||
|
||||
await IsOnline();
|
||||
//-------------hub
|
||||
var token = await localStorageService.GetItem<string>("U/key");
|
||||
|
||||
hubConnection = new HubConnectionBuilder()
|
||||
.WithUrl("http://localhost:5089/chatNotificationHub", options =>
|
||||
{
|
||||
options.AccessTokenProvider = () => Task.FromResult(token);
|
||||
})
|
||||
.WithAutomaticReconnect()
|
||||
.Build();
|
||||
|
||||
hubConnection.On<ChatItemResponseDto>("ReceiveNewChatItemFromCompany",async (chatitem) =>
|
||||
{
|
||||
if (LastOpenChat.ID == chatitem.ChatItemID)
|
||||
{
|
||||
LastOpenChat.Responses.Add(chatitem);
|
||||
StateHasChanged();
|
||||
await MarkAsRead(chatitem.ID);
|
||||
// Scroll to target if exists, otherwise scroll to bottom
|
||||
await JS.InvokeVoidAsync("scrollToTargetOrBottom");
|
||||
}
|
||||
});
|
||||
|
||||
await hubConnection.StartAsync();
|
||||
//---------end hub
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
async Task IsOnline()
|
||||
@@ -336,7 +366,6 @@
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
// Method to handle new messages from other users
|
||||
public async Task HandleNewMessage()
|
||||
{
|
||||
|
Reference in New Issue
Block a user