🐛 Fix preview back and forth navigation (#412)

This commit is contained in:
Montassar Ghanmy
2024-03-05 23:21:02 +01:00
committed by GitHub
parent b26ffb81fd
commit 5458d355f6
2 changed files with 11 additions and 2 deletions
@@ -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,
@@ -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);
}
};