1 import { useEffect, useRef, useState } from 'react';
3 import { Icon } from '@proton/components';
5 import { useLinkPath } from '../../../../store';
13 export const LocationCell = ({ shareId, parentLinkId, isTrashed }: Props) => {
14 const [location, setLocation] = useState<string>();
15 const { getPath } = useLinkPath();
17 const abortController = useRef(new AbortController());
18 const previousParentLinkId = useRef(parentLinkId);
21 void getPath(abortController.current.signal, shareId, parentLinkId).then(setLocation);
24 // Abort only when parent ID changes which means the whole location
25 // changed and is not needed anymore. All other cases we just want
26 // to update location based on the latest cache state.
27 if (previousParentLinkId.current !== parentLinkId) {
28 abortController.current.abort();
29 abortController.current = new AbortController();
30 previousParentLinkId.current = parentLinkId;
33 }, [getPath, shareId, parentLinkId]);
36 <div key="location" title={location} className="text-ellipsis">
37 <span className="text-pre">
38 {isTrashed && <Icon name="trash" className="mr-1" />}