From 5458d355f61cc73d6f86244912723f6b5297206b Mon Sep 17 00:00:00 2001 From: Montassar Ghanmy Date: Tue, 5 Mar 2024 23:21:02 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20preview=20back=20and=20for?= =?UTF-8?q?th=20navigation=20(#412)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/app/views/client/body/drive/browser.tsx | 5 +++++ .../views/client/body/drive/documents/document-row.tsx | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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 fe429ba4..3c3ba6df 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/browser.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/browser.tsx @@ -76,6 +76,11 @@ export default memo( DriveCurrentFolderAtom({ context: context, initialFolderId: dirId || viewId || initialParentId || 'user_'+user?.id }), ); + // set the initial view to the user's home directory + useEffect(() => { + !dirId && !viewId && history.push(RouterServices.generateRouteFromState({viewId: parentId})); + }, [viewId, dirId]); + const [loadingParentChange, setLoadingParentChange] = useState(false); const { sharedWithMe, diff --git a/tdrive/frontend/src/app/views/client/body/drive/documents/document-row.tsx b/tdrive/frontend/src/app/views/client/body/drive/documents/document-row.tsx index 0d8f1e9e..8682fd4c 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/documents/document-row.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/documents/document-row.tsx @@ -36,7 +36,7 @@ export const DocumentRow = ({ }: DriveItemProps) => { const history = useHistory(); const [hover, setHover] = useState(false); - const { open } = useDrivePreview(); + const { open,close } = useDrivePreview(); const company = useRouterCompany(); const { itemId } = useRouteState(); @@ -48,6 +48,11 @@ export const DocumentRow = ({ const hasThumbnails = !!metadata.thumbnails?.length || false; useEffect(() => { + // close the preview if the item is not set or the user navigated away + if(!itemId) { + close(); + } + // open the preview if the item is set if(itemId == item.id) { open(item); } @@ -58,7 +63,6 @@ export const DocumentRow = ({ console.log("DEVICE:: " + device); if (device != "ios" && device != "android") { history.push(RouterServices.generateRouteFromState({companyId: company, itemId: item.id, dirId: ''})); - //open(item); } };