diff --git a/client/src/WebsocketClient.ts b/client/src/WebsocketClient.ts
index 63e1f54..cc880c6 100644
--- a/client/src/WebsocketClient.ts
+++ b/client/src/WebsocketClient.ts
@@ -13,7 +13,7 @@ import {
import { CanvasElement } from '@/stores/CanvasElementsStore';
import { EVENT } from './types';
import { ValueOf } from './lib/misc';
-import { UpdatedTimeMessage } from './stores/WebSocketStore';
+import { BoardMetaData, UpdatedTimeMessage } from './stores/WebSocketStore';
import { Comment } from './stores/CommentsStore';
interface CallBacksType {
@@ -215,6 +215,7 @@ export default class WebsocketClient {
| string
| string[]
| UpdatedTimeMessage
+ | BoardMetaData
| null
| { elemID: string; comment: Partial }
| Record,
diff --git a/client/src/components/lib/BoardHeader.tsx b/client/src/components/lib/BoardHeader.tsx
index 2b0bb55..0c6458d 100644
--- a/client/src/components/lib/BoardHeader.tsx
+++ b/client/src/components/lib/BoardHeader.tsx
@@ -226,7 +226,9 @@ const BoardHeader = ({
fields: { serialized: state },
});
setBoardMeta({ lastModified: updated.data.updatedAt });
- updateCanvas(boardMeta.id, updated.data.updatedAt);
+ updateCanvas(boardMeta.id, {
+ updatedAt: updated.data.updatedAt,
+ });
setWebsocketAction(
{
boardID: boardMeta.id,
diff --git a/client/src/components/lib/CommentsSheetContent.tsx b/client/src/components/lib/CommentsSheetContent.tsx
index f38964f..9f2e0da 100644
--- a/client/src/components/lib/CommentsSheetContent.tsx
+++ b/client/src/components/lib/CommentsSheetContent.tsx
@@ -308,7 +308,7 @@ const CommentsSheetContent = () => {
fields: { serialized: state },
});
setBoardMeta({ lastModified: updated.data.updatedAt });
- updateCanvas(boardMeta.id, updated.data.updatedAt);
+ updateCanvas(boardMeta.id, { updatedAt: updated.data.updatedAt });
setWebsocketAction(
{
boardID: boardMeta.id,
diff --git a/client/src/components/lib/EditBoardDataDialog.tsx b/client/src/components/lib/EditBoardDataDialog.tsx
index 1bad230..7028f61 100644
--- a/client/src/components/lib/EditBoardDataDialog.tsx
+++ b/client/src/components/lib/EditBoardDataDialog.tsx
@@ -143,7 +143,9 @@ export default function EditBoardDataDialog({
folder: newFolder,
lastModified: updatedAt.data.updatedAt,
});
- updateCanvas(boardMeta.id, updatedAt.data.updatedAt);
+ updateCanvas(boardMeta.id, {
+ updatedAt: updatedAt.data.updatedAt,
+ });
updateCanvasInfo(
boardMeta.id,
newTitle ?? '',
@@ -153,9 +155,12 @@ export default function EditBoardDataDialog({
setWebsocketAction(
{
boardID: boardMeta.id,
+ title: newTitle,
+ tags: boardMeta.tags,
+ folder: newFolder,
lastModified: updatedAt.data.updatedAt,
},
- 'updateUpdatedTime',
+ 'changeBoardMeta',
);
}}
>
diff --git a/client/src/components/lib/ShareBoardDialog.tsx b/client/src/components/lib/ShareBoardDialog.tsx
index 57f4db3..ba01837 100644
--- a/client/src/components/lib/ShareBoardDialog.tsx
+++ b/client/src/components/lib/ShareBoardDialog.tsx
@@ -30,6 +30,7 @@ import { useWebSocketStore } from '@/stores/WebSocketStore';
import { REST } from '@/constants';
import { useToast } from '../ui/use-toast';
import { fetchImageFromFirebaseStorage } from '@/views/SignInPage';
+import { TrashIcon } from '@radix-ui/react-icons';
/**
* An alert dialog that is controlled by the `open` prop. It displays a list of users
@@ -50,18 +51,26 @@ const ShareBoardDialog = ({
}) => {
/* Controls visibility of the addition input. */
const [isAddUserOpen, setIsAddUserOpen] = useState(false);
- const { boardMeta, updatePermission, addUser, updateAvatars } =
- useCanvasBoardStore([
- 'boardMeta',
- 'updatePermission',
- 'addUser',
- 'updateAvatars',
- ]);
+ const {
+ boardMeta,
+ updatePermission,
+ addUser,
+ updateAvatars,
+ setBoardMeta,
+ removeCanvas,
+ } = useCanvasBoardStore([
+ 'boardMeta',
+ 'updatePermission',
+ 'addUser',
+ 'updateAvatars',
+ 'setBoardMeta',
+ 'removeCanvas',
+ ]);
const { setSelectedElements, selectedElementIds } = useCanvasElementStore([
'setSelectedElements',
'selectedElementIds',
]);
- const { setTool } = useAppStore(['setTool']);
+ const { setTool, setMode } = useAppStore(['setTool', 'setMode']);
const { socket, setWebsocketAction } = useWebSocketStore([
'socket',
'setWebsocketAction',
@@ -79,6 +88,38 @@ const ShareBoardDialog = ({
if (isOwnPerm) setSelectedElements([]);
updatePermission(collabID, permission, isOwnPerm);
});
+
+ socket?.on('removeCollab', async (msg) => {
+ const collabID = (msg as { payload: string }).payload;
+
+ if (collabID === boardMeta.collabID) {
+ setMode('dashboard');
+ toast({
+ variant: 'destructive',
+ title: `You have been removed from: ${boardMeta.title}`,
+ description: 'Ask another collaborator to add you again',
+ });
+ removeCanvas(boardMeta.id);
+ setBoardMeta({
+ title: '',
+ id: '',
+ lastModified: '',
+ roomID: '',
+ shareUrl: '',
+ folder: '',
+ tags: [],
+ collabID: '',
+ users: [],
+ permission: '',
+ });
+ return;
+ }
+ setBoardMeta({
+ users: boardMeta.users.filter(
+ (metaUser) => collabID !== metaUser.collabID,
+ ),
+ });
+ });
}, [socket, boardMeta.collabID, updatePermission]);
return (
@@ -206,46 +247,73 @@ const ShareBoardDialog = ({
{user.email}
-