/
githubmirror
/
client
Обзор
Документация
Войти
/
githubmirror
/
client
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
shared/fs/common/use-open.tsx
52 строки
2 KB
chrisnojima-zoom
Version 670 - clean2 (#29122)
08 июн 2026, 19:31
Не верифицирован
08 июн 2026, 19:31
1943197
Код
Авторство
О чём код?
import * as T from '@/constants/types' import {useSafeNavigation} from '@/util/safe-navigation' import {useFsPathItem} from './hooks' type Props = { destinationPickerSource?: T.FS.MoveOrCopySource | T.FS.IncomingShareSource path: T.FS.Path } export const useOpen = (props: Props) => { const pathItem = useFsPathItem(props.path, {loadOnMount: false, subscribe: false}) const nav = useSafeNavigation() if (!props.destinationPickerSource) { const knownType = pathItem.type !== T.FS.PathType.Unknown ? pathItem.type : undefined const knownTimestamp = pathItem.type === T.FS.PathType.File ? pathItem.lastModifiedTimestamp : undefined return () => { if (isMobile && knownType === T.FS.PathType.File) { nav.safeNavigateAppend({ name: 'fsFilePreview', params: {initialLastModifiedTimestamp: knownTimestamp, path: props.path}, }) } else { nav.safeNavigateAppend({ name: 'fsBrowse', params: {initialLastModifiedTimestamp: knownTimestamp, initialPathType: knownType, path: props.path}, }) } } } const destinationPickerSource = props.destinationPickerSource const isFolder = T.FS.getPathLevel(props.path) <= 3 || pathItem.type === T.FS.PathType.Folder const canOpenInDestinationPicker = isFolder && (destinationPickerSource.type === T.FS.DestinationPickerSource.IncomingShare ? true : destinationPickerSource.path !== props.path) if (!canOpenInDestinationPicker) { return } const destinationPickerGoTo = () => nav.safeNavigateAppend({ name: 'destinationPicker', params: {parentPath: props.path, source: destinationPickerSource}, }) return destinationPickerGoTo }