From f3c183b8002bca1d5cfc9653b265ae92b0e7cf12 Mon Sep 17 00:00:00 2001 From: Akmal Isomadinov Date: Thu, 29 Aug 2024 20:19:44 +0500 Subject: [PATCH] Client: Fixed crash in public room --- .../EmptyViewContainer/EmptyViewContainer.hooks.ts | 12 ++++++------ packages/client/src/store/TreeFoldersStore.js | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/client/src/components/EmptyContainer/sub-components/EmptyViewContainer/EmptyViewContainer.hooks.ts b/packages/client/src/components/EmptyContainer/sub-components/EmptyViewContainer/EmptyViewContainer.hooks.ts index aaf8ab1333..b5e78f7818 100644 --- a/packages/client/src/components/EmptyContainer/sub-components/EmptyViewContainer/EmptyViewContainer.hooks.ts +++ b/packages/client/src/components/EmptyContainer/sub-components/EmptyViewContainer/EmptyViewContainer.hooks.ts @@ -133,9 +133,9 @@ export const useOptions = ( newFilter.searchArea = RoomSearchArea.Active; const state = { - title: roomsFolder.title, + title: roomsFolder?.title, isRoot: true, - rootFolderType: roomsFolder.rootFolderType, + rootFolderType: roomsFolder?.rootFolderType, }; const path = getCategoryUrl(CategoryType.Shared); @@ -146,7 +146,7 @@ export const useOptions = ( }, state, }; - }, [roomsFolder.rootFolderType, roomsFolder.title, userId]); + }, [roomsFolder?.rootFolderType, roomsFolder?.title, userId]); const onGoToPersonal = useCallback((): LinkProps => { const newFilter = FilesFilter.getDefault(); @@ -154,9 +154,9 @@ export const useOptions = ( newFilter.folder = myFolderId?.toString() ?? ""; const state = { - title: myFolder.title, + title: myFolder?.title, isRoot: true, - rootFolderType: myFolder.rootFolderType, + rootFolderType: myFolder?.rootFolderType, }; const path = getCategoryUrl(CategoryType.Personal); @@ -170,7 +170,7 @@ export const useOptions = ( }, state, }; - }, [myFolder.rootFolderType, myFolder.title, myFolderId]); + }, [myFolder?.rootFolderType, myFolder?.title, myFolderId]); const onCreateRoom = useCallback(() => { if (isWarningRoomsDialog) { diff --git a/packages/client/src/store/TreeFoldersStore.js b/packages/client/src/store/TreeFoldersStore.js index c22d92a9a9..17e9d49f45 100644 --- a/packages/client/src/store/TreeFoldersStore.js +++ b/packages/client/src/store/TreeFoldersStore.js @@ -179,6 +179,9 @@ class TreeFoldersStore { return this.rootFoldersTitles[FolderType.TRASH]?.id; } + /** + * @type {import("@docspace/shared/api/files/types").TFolder=} + */ get myFolder() { return this.treeFolders.find((x) => x.rootFolderType === FolderType.USER); } @@ -196,7 +199,9 @@ class TreeFoldersStore { get recentFolder() { return this.treeFolders.find((x) => x.rootFolderType === FolderType.Recent); } - + /** + * @type {import("@docspace/shared/api/rooms/types").TRoom=} + */ get roomsFolder() { return this.treeFolders.find((x) => x.rootFolderType === FolderType.Rooms); }