🐛 Fix preview back and forth navigation (#412)
This commit is contained in:
@@ -76,6 +76,11 @@ export default memo(
|
|||||||
DriveCurrentFolderAtom({ context: context, initialFolderId: dirId || viewId || initialParentId || 'user_'+user?.id }),
|
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 [loadingParentChange, setLoadingParentChange] = useState(false);
|
||||||
const {
|
const {
|
||||||
sharedWithMe,
|
sharedWithMe,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export const DocumentRow = ({
|
|||||||
}: DriveItemProps) => {
|
}: DriveItemProps) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [hover, setHover] = useState(false);
|
const [hover, setHover] = useState(false);
|
||||||
const { open } = useDrivePreview();
|
const { open,close } = useDrivePreview();
|
||||||
const company = useRouterCompany();
|
const company = useRouterCompany();
|
||||||
const { itemId } = useRouteState();
|
const { itemId } = useRouteState();
|
||||||
|
|
||||||
@@ -48,6 +48,11 @@ export const DocumentRow = ({
|
|||||||
const hasThumbnails = !!metadata.thumbnails?.length || false;
|
const hasThumbnails = !!metadata.thumbnails?.length || false;
|
||||||
|
|
||||||
useEffect(() => {
|
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) {
|
if(itemId == item.id) {
|
||||||
open(item);
|
open(item);
|
||||||
}
|
}
|
||||||
@@ -58,7 +63,6 @@ export const DocumentRow = ({
|
|||||||
console.log("DEVICE:: " + device);
|
console.log("DEVICE:: " + device);
|
||||||
if (device != "ios" && device != "android") {
|
if (device != "ios" && device != "android") {
|
||||||
history.push(RouterServices.generateRouteFromState({companyId: company, itemId: item.id, dirId: ''}));
|
history.push(RouterServices.generateRouteFromState({companyId: company, itemId: item.id, dirId: ''}));
|
||||||
//open(item);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user