diff --git a/apps/mobile/src/components/modal/inspector/ActionsModal.tsx b/apps/mobile/src/components/modal/inspector/ActionsModal.tsx index f310ad2c9..3872dad9a 100644 --- a/apps/mobile/src/components/modal/inspector/ActionsModal.tsx +++ b/apps/mobile/src/components/modal/inspector/ActionsModal.tsx @@ -28,6 +28,7 @@ import { Modal, ModalRef } from '~/components/layout/Modal'; import { tw, twStyle } from '~/lib/tailwind'; import { useActionsModalStore } from '~/stores/modalStore'; +import { toast } from '~/components/primitive/Toast'; import FileInfoModal from './FileInfoModal'; import RenameModal from './RenameModal'; @@ -76,7 +77,11 @@ export const ActionsModal = () => { const filePath = data && getIndexedItemFilePath(data); // Open - const updateAccessTime = useLibraryMutation('files.updateAccessTime'); + const updateAccessTime = useLibraryMutation('files.updateAccessTime', { + onSuccess: () => { + rspc.queryClient.invalidateQueries(['search.paths']); + } + }); const queriedFullPath = useLibraryQuery(['files.getPath', filePath?.id ?? -1], { enabled: filePath != null }); @@ -99,9 +104,9 @@ export const ActionsModal = () => { }); filePath && filePath.object_id && - updateAccessTime.mutateAsync([filePath.object_id]).catch(console.error); + await updateAccessTime.mutateAsync([filePath.object_id]).catch(console.error); } catch (error) { - // TODO: Handle Error & toast message + toast.error("Error opening object") } } @@ -179,7 +184,7 @@ export const ActionsModal = () => { )} - + ); diff --git a/apps/mobile/src/components/modal/inspector/FileInfoModal.tsx b/apps/mobile/src/components/modal/inspector/FileInfoModal.tsx index 21ef7955e..89a9457fd 100644 --- a/apps/mobile/src/components/modal/inspector/FileInfoModal.tsx +++ b/apps/mobile/src/components/modal/inspector/FileInfoModal.tsx @@ -1,6 +1,6 @@ -import { getItemFilePath, humanizeSize, type ExplorerItem } from '@sd/client'; +import { getItemFilePath, getItemObject, humanizeSize, type ExplorerItem } from '@sd/client'; import dayjs from 'dayjs'; -import { Barcode, CaretLeft, Clock, Cube, Icon, SealCheck, Snowflake } from 'phosphor-react-native'; +import { Barcode, CaretLeft, Clock, Cube, FolderOpen, Icon, SealCheck, Snowflake } from 'phosphor-react-native'; import { forwardRef } from 'react'; import { Pressable, Text, View } from 'react-native'; import FileThumb from '~/components/explorer/FileThumb'; @@ -42,7 +42,7 @@ const FileInfoModal = forwardRef((props, ref) => { const { data } = props; const modalRef = useForwardedRef(ref); const filePathData = data && getItemFilePath(data); - + const objectData = data && getItemObject(data); return ( ((props, ref) => { /> )} + {/* Accessed */} + + + {/* Modified */} + {filePathData && 'cas_id' in filePathData && ( <> {/* Indexed */} diff --git a/apps/mobile/src/components/modal/inspector/RenameModal.tsx b/apps/mobile/src/components/modal/inspector/RenameModal.tsx index 4bc7f100b..03a4f7741 100644 --- a/apps/mobile/src/components/modal/inspector/RenameModal.tsx +++ b/apps/mobile/src/components/modal/inspector/RenameModal.tsx @@ -10,11 +10,8 @@ import useForwardedRef from '~/hooks/useForwardedRef'; import { tw } from '~/lib/tailwind'; import { useActionsModalStore } from '~/stores/modalStore'; -interface Props { - objectName: string; -} -const RenameModal = forwardRef((props, ref) => { +const RenameModal = forwardRef((_, ref) => { const modalRef = useForwardedRef(ref); const [newName, setNewName] = useState(''); const rspc = useRspcLibraryContext(); @@ -22,6 +19,9 @@ const RenameModal = forwardRef((props, ref) => { const inputRef = useRef(null); const filePathData = data && getIndexedItemFilePath(data); + const fileName = filePathData?.name ?? ''; + const fileExtension = filePathData?.extension ?? ''; + const combined = `${fileName}${fileExtension ? `.${fileExtension}` : ''}`; const renameFile = useLibraryMutation(['files.renameFile'], { onSuccess: () => { @@ -35,8 +35,9 @@ const RenameModal = forwardRef((props, ref) => { // set input value to object name on initial render useEffect(() => { - setNewName(props.objectName); - }, [props.objectName]); + if (!fileName) return; + setNewName(combined); + }, [fileName, combined]); const textRenameHandler = async () => { switch (data?.type) { @@ -66,7 +67,7 @@ const RenameModal = forwardRef((props, ref) => { setNewName(props.objectName)} + onDismiss={() => setNewName(combined)} enableContentPanningGesture={false} enablePanDownToClose={false} snapPoints={['20']} @@ -75,11 +76,11 @@ const RenameModal = forwardRef((props, ref) => { inputRef.current?.setSelection(0, newName.length)} + onFocus={() => inputRef.current?.setSelection(0, fileName.length)} value={newName} onChangeText={(t) => setNewName(t)} /> -