Warn on Refresh Metadata (#610)
* Warn the user about the dangers of refresh metadata and promote them to use a scan instead. * Removed presence hub and moved it over to message hub. When a library scan is in progress, now a spinner will show on manage libraries page. * Code cleanup
This commit is contained in:
parent
9b536ce700
commit
0ac54e682f
17 changed files with 101 additions and 77 deletions
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using API.Extensions;
|
||||
using API.SignalR.Presence;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
|
|
@ -13,8 +15,14 @@ namespace API.SignalR
|
|||
[Authorize]
|
||||
public class MessageHub : Hub
|
||||
{
|
||||
private readonly IPresenceTracker _tracker;
|
||||
private static readonly HashSet<string> Connections = new HashSet<string>();
|
||||
|
||||
public MessageHub(IPresenceTracker tracker)
|
||||
{
|
||||
_tracker = tracker;
|
||||
}
|
||||
|
||||
public static bool IsConnected
|
||||
{
|
||||
get
|
||||
|
|
@ -33,6 +41,12 @@ namespace API.SignalR
|
|||
Connections.Add(Context.ConnectionId);
|
||||
}
|
||||
|
||||
await _tracker.UserConnected(Context.User.GetUsername(), Context.ConnectionId);
|
||||
|
||||
var currentUsers = await PresenceTracker.GetOnlineUsers();
|
||||
await Clients.All.SendAsync(SignalREvents.OnlineUsers, currentUsers);
|
||||
|
||||
|
||||
await base.OnConnectedAsync();
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +57,12 @@ namespace API.SignalR
|
|||
Connections.Remove(Context.ConnectionId);
|
||||
}
|
||||
|
||||
await _tracker.UserDisconnected(Context.User.GetUsername(), Context.ConnectionId);
|
||||
|
||||
var currentUsers = await PresenceTracker.GetOnlineUsers();
|
||||
await Clients.All.SendAsync(SignalREvents.OnlineUsers, currentUsers);
|
||||
|
||||
|
||||
await base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue