This commit is contained in:
2026-03-08 00:27:53 +01:00
parent c4ee5b0394
commit 9a3143d2f0
4 changed files with 8 additions and 73 deletions

View File

@@ -1,6 +1,7 @@
using AipsCore.Application.Abstract;
using AipsCore.Application.Models.Whiteboard.Query.GetWhiteboardInfoRT;
using AipsCore.Domain.Models.Shape.Enums;
using AipsCore.Domain.Models.WhiteboardMembership.Enums;
using AipsRT.Model.Whiteboard.Shapes.Map;
using AipsRT.Model.Users;

View File

@@ -6,12 +6,9 @@ namespace AipsRT.Model.Whiteboard;
public class Whiteboard
{
public Guid WhiteboardId { get; set; }
public Guid OwnerId { get; set; }
public HashSet<Guid> AcceptedUsers { get; } = new();
public HashSet<Guid> PendingUsers { get; } = new();
public List<User> Users { get; } = [];
public List<Shape> Shapes { get; } = [];
@@ -26,36 +23,24 @@ public class Whiteboard
Shapes.Add(shape);
Rectangles.Add(shape);
}
public void AddArrow(Arrow shape)
{
Shapes.Add(shape);
Arrows.Add(shape);
}
public void AddLine(Line shape)
{
Shapes.Add(shape);
Lines.Add(shape);
}
public void AddTextShape(TextShape shape)
{
Shapes.Add(shape);
TextShapes.Add(shape);
}
public void AddUser(User user) => Users.Add(user);
public void AddPendingUser(Guid userId) => PendingUsers.Add(userId);
public void AcceptUser(Guid userId)
{
PendingUsers.Remove(userId);
AcceptedUsers.Add(userId);
}
public void RejectUser(Guid userId) => PendingUsers.Remove(userId);
public bool IsAccepted(Guid userId) => AcceptedUsers.Contains(userId);
}

View File

@@ -56,33 +56,4 @@ public class WhiteboardManager
{
return GetWhiteboard(GetUserWhiteboard(userId));
}
public void AddPendingUser(Guid userId, Guid whiteboardId)
{
var wb = GetWhiteboard(whiteboardId)!;
wb.AddPendingUser(userId);
_userInWhiteboards[userId] = whiteboardId;
}
public void MovePendingToAccepted(Guid userId, Guid whiteboardId)
{
var wb = GetWhiteboard(whiteboardId)!;
wb.AcceptUser(userId);
}
public void RemovePendingUser(Guid userId, Guid whiteboardId)
{
var whiteboard = GetWhiteboard(whiteboardId)!;
whiteboard.RejectUser(userId);
_userInWhiteboards.TryRemove(userId, out _);
}
public bool IsAccepted(Guid userId)
{
if (!_userInWhiteboards.TryGetValue(userId, out var whiteboardId))
return false;
var whiteboard = GetWhiteboard(whiteboardId);
return whiteboard?.IsAccepted(userId) ?? false;
}
}