From b10292b88039e5a1a9b2012d4217d344ce0ed3a3 Mon Sep 17 00:00:00 2001 From: Veljko Tosic Date: Mon, 9 Mar 2026 21:13:21 +0100 Subject: [PATCH 1/4] Active users copied to last valid state upon invalidation --- dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs | 11 ++++++++--- dotnet/AipsRT/Services/RtErrorHandleStrategy.cs | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs b/dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs index 87a728e..fa8bc5f 100644 --- a/dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs +++ b/dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs @@ -14,8 +14,7 @@ public class Whiteboard public List ActiveUsers { get; } = []; public void AddActiveUser(User user) => ActiveUsers.Add(user); - public void RemoveActiveUser(Guid userId) - => ActiveUsers.RemoveAll(u => u.UserId == userId); + public void RemoveActiveUser(Guid userId) => ActiveUsers.RemoveAll(u => u.UserId == userId); public List Shapes { get; } = []; @@ -48,5 +47,11 @@ public class Whiteboard TextShapes.Add(shape); } - public void AddUser(User user) => Users.Add(user); + public void AddUser(User user) + { + if (!Users.Contains(user)) + { + Users.Add(user); + } + } } \ No newline at end of file diff --git a/dotnet/AipsRT/Services/RtErrorHandleStrategy.cs b/dotnet/AipsRT/Services/RtErrorHandleStrategy.cs index 3f14796..2669f2f 100644 --- a/dotnet/AipsRT/Services/RtErrorHandleStrategy.cs +++ b/dotnet/AipsRT/Services/RtErrorHandleStrategy.cs @@ -18,9 +18,16 @@ public class RtErrorHandleStrategy : IErrorMessageHandleStrategy public async Task Handle(ErrorMessage message, CancellationToken cancellationToken) { + var activeUsers = _whiteboardManager.GetWhiteboard(message.WhiteboardId)!.ActiveUsers; + await _whiteboardManager.LoadWhiteboard(message.WhiteboardId); var whiteboard = _whiteboardManager.GetWhiteboard(message.WhiteboardId)!; + + foreach (var user in activeUsers) + { + whiteboard.AddActiveUser(user); + } await _hubContext.Clients .Group(whiteboard.WhiteboardId.ToString()) From 10b550a59ab28325fd7bea868f91389e2bc45e92 Mon Sep 17 00:00:00 2001 From: Veljko Tosic Date: Mon, 9 Mar 2026 21:24:01 +0100 Subject: [PATCH 2/4] Code only displayed for owner and is not lost on refresh --- dotnet/AipsRT/Model/Whiteboard/GetWhiteboardService.cs | 3 ++- dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs | 2 ++ front/src/components/whiteboard/WhiteboardToolbar.vue | 10 ++++++++-- front/src/types/whiteboard.ts | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dotnet/AipsRT/Model/Whiteboard/GetWhiteboardService.cs b/dotnet/AipsRT/Model/Whiteboard/GetWhiteboardService.cs index 68f72ed..593ae1b 100644 --- a/dotnet/AipsRT/Model/Whiteboard/GetWhiteboardService.cs +++ b/dotnet/AipsRT/Model/Whiteboard/GetWhiteboardService.cs @@ -28,7 +28,8 @@ public class GetWhiteboardService { WhiteboardId = entity.Id, OwnerId = entity.OwnerId, - Owner = new User(entity.Owner.Id, entity.Owner.UserName!, entity.Owner.Email!) + Owner = new User(entity.Owner.Id, entity.Owner.UserName!, entity.Owner.Email!), + Code = entity.Code, }; foreach (var membership in entity.Memberships) diff --git a/dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs b/dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs index fa8bc5f..711ff49 100644 --- a/dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs +++ b/dotnet/AipsRT/Model/Whiteboard/Whiteboard.cs @@ -9,6 +9,8 @@ public class Whiteboard public Guid OwnerId { get; set; } public User Owner { get; set; } = null!; + + public string Code {get; set;} public List Users { get; } = []; diff --git a/front/src/components/whiteboard/WhiteboardToolbar.vue b/front/src/components/whiteboard/WhiteboardToolbar.vue index 23739ed..492c9ac 100644 --- a/front/src/components/whiteboard/WhiteboardToolbar.vue +++ b/front/src/components/whiteboard/WhiteboardToolbar.vue @@ -23,6 +23,12 @@ const colors = ['#4f9dff', '#ff4f4f', '#4fff4f', '#ffff4f', '#ff4fff', '#ffffff' const isReadOnly = computed(() => sessionStore.selectedTool === 'hand' && !!sessionStore.selectedShape) +const isOwner = computed(() => { + const wb = sessionStore.whiteboard + if (!wb || !auth.user) return false + return wb.ownerId === auth.user.userId +}) + const showProperties = computed(() => { if (['rectangle', 'arrow', 'line', 'text'].includes(sessionStore.selectedTool)) return true if (sessionStore.selectedTool === 'hand' && sessionStore.selectedShape) return true @@ -61,7 +67,7 @@ const displayTextSize = computed(() => { const showCopiedTooltip = ref(false) -const whiteboardCode = computed(() => infoStore.getCurrentWhiteboard()?.code || '') +const whiteboardCode = computed(() => sessionStore.whiteboard!.code) const copyCodeToClipboard = async () => { console.info(whiteboardCode.value) @@ -166,7 +172,7 @@ const copyCodeToClipboard = async () => { -
+