diff --git a/tdrive/frontend/src/app/components/search-popup/parts/drive-item-result.tsx b/tdrive/frontend/src/app/components/search-popup/parts/drive-item-result.tsx index f85f2f66..5c477444 100644 --- a/tdrive/frontend/src/app/components/search-popup/parts/drive-item-result.tsx +++ b/tdrive/frontend/src/app/components/search-popup/parts/drive-item-result.tsx @@ -30,13 +30,16 @@ import Media from '@molecules/media'; import { DriveCurrentFolderAtom } from '@views/client/body/drive/browser'; import { useHistory } from 'react-router-dom'; import RouterServices from '@features/router/services/router-service'; +import { useCurrentUser } from 'app/features/users/hooks/use-current-user'; + export default (props: { driveItem: DriveItem & { user?: UserType } }) => { const history = useHistory(); const input = useRecoilValue(SearchInputState); const currentWorkspaceId = useRouterWorkspace(); const companyApplications = useCompanyApplications(); - const [_, setParentId] = useRecoilState(DriveCurrentFolderAtom({ initialFolderId: 'root' })); + const { user } = useCurrentUser(); + const [_, setParentId] = useRecoilState(DriveCurrentFolderAtom({ initialFolderId: 'user_'+user?.id })); const tdriveDriveApplicationId = companyApplications.applications.find(application => { return application.identity.code === 'tdrive_drive'; diff --git a/tdrive/frontend/src/app/views/client/body/drive/browser.tsx b/tdrive/frontend/src/app/views/client/body/drive/browser.tsx index 33c88794..3aad0836 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/browser.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/browser.tsx @@ -35,6 +35,7 @@ import useRouteState from 'app/features/router/hooks/use-route-state'; import { SharedWithMeFilterState } from '@features/drive/state/shared-with-me-filter'; import MenusManager from '@components/menus/menus-manager.jsx'; import Languages from 'features/global/services/languages-service'; +import { useCurrentUser } from 'app/features/users/hooks/use-current-user'; export const DriveCurrentFolderAtom = atomFamily< string, @@ -56,12 +57,13 @@ export default memo( tdriveTabContextToken?: string; inPublicSharing?: boolean; }) => { + const { user } = useCurrentUser(); const companyId = useRouterCompany(); setTdriveTabToken(tdriveTabContextToken || null); const [filter, setFilter] = useRecoilState(SharedWithMeFilterState); const [parentId, _setParentId] = useRecoilState( - DriveCurrentFolderAtom({ context: context, initialFolderId: initialParentId || 'root' }), + DriveCurrentFolderAtom({ context: context, initialFolderId: initialParentId || 'user_'+user?.id }), ); const [loadingParentChange, setLoadingParentChange] = useState(false); @@ -105,7 +107,7 @@ export default memo( //In case we are kicked out of the current folder, we need to reset the parent id useEffect(() => { - if (!loading && !path?.length && !inPublicSharing && !sharedWithMe) setParentId('root'); + if (!loading && !path?.length && !inPublicSharing && !sharedWithMe) setParentId('user_'+user?.id); }, [path, loading, setParentId]); useEffect(() => { diff --git a/tdrive/frontend/src/app/views/client/common/disk-usage.tsx b/tdrive/frontend/src/app/views/client/common/disk-usage.tsx index 4fd3e92a..335018cf 100644 --- a/tdrive/frontend/src/app/views/client/common/disk-usage.tsx +++ b/tdrive/frontend/src/app/views/client/common/disk-usage.tsx @@ -1,14 +1,16 @@ import { Base, Title } from '@atoms/text'; import { useDriveItem } from '@features/drive/hooks/use-drive-item'; import { formatBytes } from '@features/drive/utils'; +import { useCurrentUser } from 'app/features/users/hooks/use-current-user'; import Languages from "features/global/services/languages-service"; export default () => { const { access, item } = useDriveItem('root'); const { item: trash } = useDriveItem('trash'); + const { user } = useCurrentUser(); return ( <> - {access !== 'read' && item?.id === 'root' && ( + {access !== 'read' && (
diff --git a/tdrive/frontend/src/app/views/client/side-bar/actions.tsx b/tdrive/frontend/src/app/views/client/side-bar/actions.tsx index 3e8a6398..7c2dea06 100644 --- a/tdrive/frontend/src/app/views/client/side-bar/actions.tsx +++ b/tdrive/frontend/src/app/views/client/side-bar/actions.tsx @@ -12,6 +12,7 @@ import { ConfirmDeleteModalAtom } from '../body/drive/modals/confirm-delete'; import { CreateModal, CreateModalAtom } from '../body/drive/modals/create'; import { Button } from '@atoms/button/button'; import Languages from "features/global/services/languages-service"; +import { useCurrentUser } from 'app/features/users/hooks/use-current-user'; export const CreateModalWithUploadZones = ({ initialParentId }: { initialParentId?: string }) => { const companyId = useRouterCompany(); @@ -19,8 +20,9 @@ export const CreateModalWithUploadZones = ({ initialParentId }: { initialParentI const uploadFolderZoneRef = useRef<UploadZone | null>(null); const setCreationModalState = useSetRecoilState(CreateModalAtom); const { uploadTree, uploadFromUrl } = useDriveUpload(); + const { user } = useCurrentUser(); const [parentId, _] = useRecoilState( - DriveCurrentFolderAtom({ initialFolderId: initialParentId || 'root' }), + DriveCurrentFolderAtom({ initialFolderId: initialParentId || 'user_'+user?.id }), ); console.log("Upload Zone:: " + parentId); @@ -78,7 +80,8 @@ export const CreateModalWithUploadZones = ({ initialParentId }: { initialParentI }; export default () => { - const [parentId, _] = useRecoilState(DriveCurrentFolderAtom({ initialFolderId: 'root' })); + const { user } = useCurrentUser(); + const [parentId, _] = useRecoilState(DriveCurrentFolderAtom({ initialFolderId: 'user_'+user?.id })); const { access, item, inTrash } = useDriveItem(parentId); const { children: trashChildren } = useDriveItem('trash'); const uploadZoneRef = useRef<UploadZone | null>(null); diff --git a/tdrive/frontend/src/app/views/client/side-bar/index.tsx b/tdrive/frontend/src/app/views/client/side-bar/index.tsx index 9c6a6105..43ce67af 100644 --- a/tdrive/frontend/src/app/views/client/side-bar/index.tsx +++ b/tdrive/frontend/src/app/views/client/side-bar/index.tsx @@ -27,15 +27,15 @@ import Languages from "features/global/services/languages-service"; export default () => { const history = useHistory(); + const { user } = useCurrentUser(); const location = useLocation(); const company = useRouterCompany(); const workspace = useRouterWorkspace(); const [parentId, setParentId] = useRecoilState( - DriveCurrentFolderAtom({ initialFolderId: 'root' }), + DriveCurrentFolderAtom({ initialFolderId: 'user_'+user?.id }), ); - const { user } = useCurrentUser(); const active = false; - const { access: rootAccess } = useDriveItem('root'); + const { access: rootAccess } = useDriveItem('user_'+user?.id); const { sharedWithMe, inTrash, path } = useDriveItem(parentId); const activeClass = 'bg-zinc-50 dark:bg-zinc-800 !text-blue-500'; let folderType = 'home';