TagSpaces is an offline, open source, document manager with tagging support
fix: Connect location works only the first time
sytolk44ea4c598d2f
diff --git a/src/renderer/components/LocationManager.tsx b/src/renderer/components/LocationManager.tsxindex c78eb21a2..9625ec7a1 100644--- a/src/renderer/components/LocationManager.tsx+++ b/src/renderer/components/LocationManager.tsx@@ -61,13 +61,14 @@ function LocationManager(props: Props) {addLocations,editLocation,selectedLocation,+ setSelectedLocation,locationDirectoryContextMenuAnchorEl,} = useCurrentLocationContext();+const locations: Array<TS.Location> = useSelector(getLocations);// const loading: boolean = useSelector(isLoading);//const language: string = useSelector(getCurrentLanguage);const fileInputRef = useRef<HTMLInputElement>(null);- //const selectedLocation = useRef<TS.Location>(null);const [isEditLocationDialogOpened, setEditLocationDialogOpened] =useState<boolean>(false);const [isDeleteLocationDialogOpened, setDeleteLocationDialogOpened] =@@ -82,9 +83,6 @@ function LocationManager(props: Props) {const ImportLocationsDialog =Pro && Pro.UI ? Pro.UI.ImportLocationsDialog : false;- /*function setSelectedLocation(location: TS.Location) {- selectedLocation.current = location;- }*/function handleFileInputChange(selection: any) {const target = selection.currentTarget;const file = target.files[0];@@ -152,9 +150,10 @@ function LocationManager(props: Props) {// importLocations={() => setImportLocationsDialogOpened(true)}exportLocations={() => setExportLocationsDialogOpened(true)}classes={classes}- showCreateLocationDialog={() =>- dispatch(AppActions.toggleLocationDialog())- }+ showCreateLocationDialog={() => {+ setSelectedLocation(undefined);+ dispatch(AppActions.toggleLocationDialog());+ }}toggleOpenLinkDialog={() => dispatch(AppActions.toggleOpenLinkDialog())}/>{locationDirectoryContextMenuAnchorEl && (@@ -206,8 +205,6 @@ function LocationManager(props: Props) {setDeleteLocationDialogOpened={setDeleteLocationDialogOpened}- /*selectedLocation={selectedLocation.current}- setSelectedLocation={setSelectedLocation}*//></div>)}@@ -230,7 +227,6 @@ function LocationManager(props: Props) {<CreateEditLocationDialogAsyncopen={isEditLocationDialogOpened}onClose={() => setEditLocationDialogOpened(false)}- /*location={selectedLocation.current}*/editLocation={(location) => editLocation(location)}/>)}diff --git a/src/renderer/components/menus/LocationManagerMenu.tsx b/src/renderer/components/menus/LocationManagerMenu.tsxindex 16db3ed03..2bf3d062c 100644--- a/src/renderer/components/menus/LocationManagerMenu.tsx+++ b/src/renderer/components/menus/LocationManagerMenu.tsx@@ -28,10 +28,8 @@ import classNames from 'classnames';import Typography from '@mui/material/Typography';import IconButton from '@mui/material/IconButton';import MoreVertIcon from '@mui/icons-material/MoreVert';-import { useDispatch } from 'react-redux';import AppConfig from '-/AppConfig';import { Pro } from '../../pro';-import { AppDispatch } from '-/reducers/app';import Links from 'assets/links';import { ProLabel } from '-/components/HelperComponents';import {@@ -66,7 +64,6 @@ function LocationManagerMenu(props: Props) {const { closeAllLocations } = useCurrentLocationContext();const [locationManagerMenuAnchorEl, setLocationManagerMenuAnchorEl] =useState<null | HTMLElement>(null);- const dispatch: AppDispatch = useDispatch();const menuItems = [];if (!AppConfig.locationsReadOnly) {menuItems.push(diff --git a/src/renderer/hooks/CurrentLocationContextProvider.tsx b/src/renderer/hooks/CurrentLocationContextProvider.tsxindex 5fb472e68..d5a05adc5 100644--- a/src/renderer/hooks/CurrentLocationContextProvider.tsx+++ b/src/renderer/hooks/CurrentLocationContextProvider.tsx@@ -108,7 +108,8 @@ export const CurrentLocationContextProvider = ({const { showNotification } = useNotificationContext();const [currentLocation, setCurrentLocation] =useState<TS.Location>(undefined);- const selectedLocation = useRef<TS.Location>(undefined);+ const [selectedLocation, setSelectedLocation] =+ useState<TS.Location>(undefined);const skipInitialDirList = useRef<boolean>(false);const [locationDirectoryContextMenuAnchorEl,@@ -180,10 +181,6 @@ export const CurrentLocationContextProvider = ({return Promise.resolve(locationPath);}- function setSelectedLocation(location: TS.Location) {- selectedLocation.current = location;- }-function setDefaultLocations() {PlatformIO.getDevicePaths().then((devicePaths) => {@@ -422,14 +419,15 @@ export const CurrentLocationContextProvider = ({switchLocationTypeByID,changeLocationByID,openLocationById,- selectedLocation: selectedLocation.current,+ selectedLocation,+ setSelectedLocation,locationDirectoryContextMenuAnchorEl,setLocationDirectoryContextMenuAnchorEl,- setSelectedLocation,getLocationPosition,};}, [currentLocation,+ selectedLocation,persistTagsInSidecarFile,skipInitialDirList.current,locationDirectoryContextMenuAnchorEl,