From 102710dc7f5e77f8e75c1f7deae2cbb902ae3b3c Mon Sep 17 00:00:00 2001 From: nikec <43032218+niikeec@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:51:02 +0200 Subject: [PATCH] [ENG-1109] Fix explorer double click (#1346) fix double click --- interface/app/$libraryId/Explorer/View/index.tsx | 11 ++++------- interface/app/$libraryId/Explorer/config.ts | 14 -------------- 2 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 interface/app/$libraryId/Explorer/config.ts diff --git a/interface/app/$libraryId/Explorer/View/index.tsx b/interface/app/$libraryId/Explorer/View/index.tsx index f60bdd97e..2ff05896e 100644 --- a/interface/app/$libraryId/Explorer/View/index.tsx +++ b/interface/app/$libraryId/Explorer/View/index.tsx @@ -1,5 +1,5 @@ -import clsx from 'clsx'; import { Columns, GridFour, MonitorPlay, Rows, type Icon } from '@phosphor-icons/react'; +import clsx from 'clsx'; import { isValidElement, memo, @@ -25,13 +25,12 @@ import { type Object } from '@sd/client'; import { ContextMenu, dialogManager, ModifierKeys, toast } from '@sd/ui'; - import { Loader } from '~/components'; import { useOperatingSystem } from '~/hooks'; import { isNonEmpty } from '~/util'; import { usePlatform } from '~/util/Platform'; + import CreateDialog from '../../settings/library/tags/CreateDialog'; -import { useExplorerConfigStore } from '../config'; import { useExplorerContext } from '../Context'; import { QuickPreview } from '../QuickPreview'; import { useQuickPreviewContext } from '../QuickPreview/Context'; @@ -51,8 +50,6 @@ export const ViewItem = ({ data, children, ...props }: ViewItemProps) => { const explorer = useExplorerContext(); const explorerView = useExplorerViewContext(); - const explorerConfig = useExplorerConfigStore(); - const navigate = useNavigate(); const { library } = useLibraryContext(); const { openFilePaths } = usePlatform(); @@ -110,7 +107,7 @@ export const ViewItem = ({ data, children, ...props }: ViewItemProps) => { ); if (items.paths.length > 0 && !explorerView.isRenaming) { - if (explorerConfig.openOnDoubleClick && openFilePaths) { + if (explorer.settingsStore.openOnDoubleClick === 'openFile' && openFilePaths) { updateAccessTime .mutateAsync(items.paths.map(({ object_id }) => object_id!).filter(Boolean)) .catch(console.error); @@ -123,7 +120,7 @@ export const ViewItem = ({ data, children, ...props }: ViewItemProps) => { } catch (error) { toast.error({ title: 'Failed to open file', body: `Error: ${error}.` }); } - } else if (!explorerConfig.openOnDoubleClick) { + } else if (explorer.settingsStore.openOnDoubleClick === 'quickPreview') { if (data.type !== 'Location' && !(isPath(data) && data.item.is_dir)) { getQuickPreviewStore().itemIndex = itemIndex; getQuickPreviewStore().open = true; diff --git a/interface/app/$libraryId/Explorer/config.ts b/interface/app/$libraryId/Explorer/config.ts deleted file mode 100644 index d0100a560..000000000 --- a/interface/app/$libraryId/Explorer/config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { useSnapshot } from 'valtio'; -import { DoubleClickAction, valtioPersist } from '@sd/client'; - -export const explorerConfigStore = valtioPersist('explorer-config', { - openOnDoubleClick: 'openFile' as DoubleClickAction -}); - -export function useExplorerConfigStore() { - return useSnapshot(explorerConfigStore); -} - -export function getExplorerConfigStore() { - return explorerConfigStore; -}