[ENG-1109] Fix explorer double click (#1346)

fix double click
This commit is contained in:
nikec
2023-09-13 15:51:02 +02:00
committed by GitHub
parent ae4c3d0e6b
commit 102710dc7f
2 changed files with 4 additions and 21 deletions

View File

@@ -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;

View File

@@ -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;
}