Active users copied to last valid state upon invalidation
This commit is contained in:
@@ -14,8 +14,7 @@ public class Whiteboard
|
|||||||
|
|
||||||
public List<User> ActiveUsers { get; } = [];
|
public List<User> ActiveUsers { get; } = [];
|
||||||
public void AddActiveUser(User user) => ActiveUsers.Add(user);
|
public void AddActiveUser(User user) => ActiveUsers.Add(user);
|
||||||
public void RemoveActiveUser(Guid userId)
|
public void RemoveActiveUser(Guid userId) => ActiveUsers.RemoveAll(u => u.UserId == userId);
|
||||||
=> ActiveUsers.RemoveAll(u => u.UserId == userId);
|
|
||||||
|
|
||||||
public List<Shape> Shapes { get; } = [];
|
public List<Shape> Shapes { get; } = [];
|
||||||
|
|
||||||
@@ -48,5 +47,11 @@ public class Whiteboard
|
|||||||
TextShapes.Add(shape);
|
TextShapes.Add(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddUser(User user) => Users.Add(user);
|
public void AddUser(User user)
|
||||||
|
{
|
||||||
|
if (!Users.Contains(user))
|
||||||
|
{
|
||||||
|
Users.Add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -18,9 +18,16 @@ public class RtErrorHandleStrategy : IErrorMessageHandleStrategy
|
|||||||
|
|
||||||
public async Task Handle(ErrorMessage message, CancellationToken cancellationToken)
|
public async Task Handle(ErrorMessage message, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
var activeUsers = _whiteboardManager.GetWhiteboard(message.WhiteboardId)!.ActiveUsers;
|
||||||
|
|
||||||
await _whiteboardManager.LoadWhiteboard(message.WhiteboardId);
|
await _whiteboardManager.LoadWhiteboard(message.WhiteboardId);
|
||||||
|
|
||||||
var whiteboard = _whiteboardManager.GetWhiteboard(message.WhiteboardId)!;
|
var whiteboard = _whiteboardManager.GetWhiteboard(message.WhiteboardId)!;
|
||||||
|
|
||||||
|
foreach (var user in activeUsers)
|
||||||
|
{
|
||||||
|
whiteboard.AddActiveUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
await _hubContext.Clients
|
await _hubContext.Clients
|
||||||
.Group(whiteboard.WhiteboardId.ToString())
|
.Group(whiteboard.WhiteboardId.ToString())
|
||||||
|
|||||||
Reference in New Issue
Block a user