Dashboard Customization Polish (#2295)
This commit is contained in:
parent
25e759d301
commit
25ffb2ffe1
42 changed files with 255 additions and 258 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.SignalR.Presence;
|
||||
|
|
@ -55,8 +56,7 @@ public class EventHub : IEventHub
|
|||
/// <returns></returns>
|
||||
public async Task SendMessageToAsync(string method, SignalRMessage message, int userId)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId) ?? throw new InvalidOperationException();
|
||||
await _messageHub.Clients.User(user.UserName!).SendAsync(method, message);
|
||||
await _messageHub.Clients.Users(new List<string>() {userId + string.Empty}).SendAsync(method, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ public class MessageHub : Hub
|
|||
|
||||
public override async Task OnConnectedAsync()
|
||||
{
|
||||
await _tracker.UserConnected(Context.User!.GetUserId(), Context.ConnectionId);
|
||||
var userId = Context.User!.GetUserId();
|
||||
await _tracker.UserConnected(userId, Context.ConnectionId);
|
||||
|
||||
var currentUsers = await PresenceTracker.GetOnlineUsers();
|
||||
await Clients.All.SendAsync(MessageFactory.OnlineUsers, currentUsers);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,10 @@ public class PresenceTracker : IPresenceTracker
|
|||
string[] onlineUsers;
|
||||
lock (OnlineUsers)
|
||||
{
|
||||
onlineUsers = OnlineUsers.OrderBy(k => k.Value.UserName).Select(k => k.Value.UserName).ToArray();
|
||||
onlineUsers = OnlineUsers
|
||||
.Select(k => k.Value.UserName)
|
||||
.Order()
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
return Task.FromResult(onlineUsers);
|
||||
|
|
@ -91,7 +94,10 @@ public class PresenceTracker : IPresenceTracker
|
|||
int[] onlineUsers;
|
||||
lock (OnlineUsers)
|
||||
{
|
||||
onlineUsers = OnlineUsers.Where(pair => pair.Value.IsAdmin).OrderBy(k => k.Key).Select(k => k.Key).ToArray();
|
||||
onlineUsers = OnlineUsers.Where(pair => pair.Value.IsAdmin)
|
||||
.Select(k => k.Key)
|
||||
.Order()
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue