[ENG-762] Fix rename (#981)

Fix rename cache
This commit is contained in:
nikec authored and GitHub committed 2023-06-20 22:12:14 +00:00
1 parent 37bf788ca5
commit a349fe8d50
1 file changed
+4 -2
@@ -1,7 +1,7 @@
import clsx from 'clsx';
import { HTMLAttributes, useEffect, useRef, useState } from 'react';
import { useKey } from 'rooks';
import { FilePath, useLibraryMutation, useLibraryQuery } from '@sd/client';
import { FilePath, useLibraryMutation, useRspcLibraryContext } from '@sd/client';
import { showAlertDialog } from '~/components';
import useClickOutside from '~/hooks/useClickOutside';
import { useOperatingSystem } from '~/hooks/useOperatingSystem';
@@ -16,6 +16,7 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
export default ({ filePathData, className, activeClassName, disabled, ...props }: Props) => {
const explorerView = useExplorerViewContext();
const os = useOperatingSystem();
const rspc = useRspcLibraryContext();
const ref = useRef<HTMLDivElement>(null);
@@ -23,7 +24,8 @@ export default ({ filePathData, className, activeClassName, disabled, ...props }
const [renamable, setRenamable] = useState(false);
const renameFile = useLibraryMutation(['files.renameFile'], {
onError: () => reset()
onError: () => reset(),
onSuccess: () => rspc.queryClient.invalidateQueries(['search.paths'])
});
const fileName = `${filePathData?.name}${