Skip to content

Commit

Permalink
Fix all the files affected by changing paths to be an array
Browse files Browse the repository at this point in the history
  • Loading branch information
guergana committed Jun 2, 2024
1 parent af2f975 commit 2b23a80
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 30 deletions.
6 changes: 3 additions & 3 deletions client/components/Application/Buttons/Manage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DropdownButton from '../../Parts/Buttons/Dropdown'
import { useStore, selectors } from '../store'

export default function ManageButton() {
const path = useStore((state) => state.path)
const path = useStore((state) => state.paths)
const notIndexedFiles = useStore(selectors.notIndexedFiles)
return (
<DropdownButton
Expand All @@ -24,7 +24,7 @@ export default function ManageButton() {
}

function CopyButton() {
const path = useStore((state) => state.path)
const path = useStore((state) => state.paths)
const updateState = useStore((state) => state.updateState)
const isFolder = useStore(selectors.isFolder)
const type = isFolder ? 'Folder' : 'File'
Expand All @@ -40,7 +40,7 @@ function CopyButton() {
}

function MoveButton() {
const path = useStore((state) => state.path)
const path = useStore((state) => state.paths)
const updateState = useStore((state) => state.updateState)
const isFolder = useStore(selectors.isFolder)
const type = isFolder ? 'Folder' : 'File'
Expand Down
2 changes: 1 addition & 1 deletion client/components/Application/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useStore } from './store'
export default function Content() {
const record = useStore((state) => state.record)
const indexing = useStore((state) => state.indexing)
const path = useStore((state) => state.path)
const path = useStore((state) => state.paths)
return indexing ? (
<LoadingContent />
) : record && path ? (
Expand Down
10 changes: 5 additions & 5 deletions client/components/Application/Dialogs/CopyFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import InputDialog from '../../Parts/Dialogs/Input'
import { useStore } from '../store'

export default function CopyFileDialog() {
const path = useStore((state) => state.path)
const paths = useStore((state) => state.paths)
const copyFile = useStore((state) => state.copyFile)
const updateState = useStore((state) => state.updateState)
if (!path) return null
if (!paths || paths.length > 1) return null
return (
<InputDialog
open={true}
value={path}
value={paths[0]}
title="Copy File"
label="Copy"
Icon={ContentCopyIcon}
placholder="Enter a path"
description={`You are copying "${path}". Enter destination:`}
description={`You are copying "${paths[0]}". Enter destination:`}
onCancel={() => updateState({ dialog: undefined })}
onConfirm={async (toPath) => {
await copyFile(path, toPath)
await copyFile(paths[0], toPath)
updateState({ dialog: undefined })
}}
/>
Expand Down
10 changes: 5 additions & 5 deletions client/components/Application/Dialogs/CopyFolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import InputDialog from '../../Parts/Dialogs/Input'
import { useStore } from '../store'

export default function CopyFolderDialog() {
const path = useStore((state) => state.path)
const paths = useStore((state) => state.paths)
const copyFolder = useStore((state) => state.copyFolder)
const updateState = useStore((state) => state.updateState)
if (!path) return null
if (!paths || paths.length > 1) return null
return (
<InputDialog
open={true}
value={path}
value={paths[0]}
title="Copy Folder"
label="Copy"
Icon={ContentCopyIcon}
placholder="Enter a path"
description={`You are copying "${path}". Enter destination:`}
description={`You are copying "${paths[0]}". Enter destination:`}
onCancel={() => updateState({ dialog: undefined })}
onConfirm={async (toPath) => {
await copyFolder(path, toPath)
await copyFolder(paths[0], toPath)
updateState({ dialog: undefined })
}}
/>
Expand Down
6 changes: 3 additions & 3 deletions client/components/Application/Dialogs/DeleteFolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import ConfirmDialog from '../../Parts/Dialogs/Confirm'
import { useStore } from '../store'

export default function DeleteFolderDialog() {
const path = useStore((state) => state.path)
const paths = useStore((state) => state.paths)
const deleteFolder = useStore((state) => state.deleteFolder)
const updateState = useStore((state) => state.updateState)
if (!path) return null
if (!paths || paths.length > 1) return null
return (
<ConfirmDialog
open={true}
Expand All @@ -15,7 +15,7 @@ export default function DeleteFolderDialog() {
cancelLabel="No"
onCancel={() => updateState({ dialog: undefined })}
onConfirm={async () => {
await deleteFolder(path)
await deleteFolder(paths[0])
updateState({ dialog: undefined })
}}
/>
Expand Down
10 changes: 5 additions & 5 deletions client/components/Application/Dialogs/MoveFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import InputDialog from '../../Parts/Dialogs/Input'
import { useStore } from '../store'

export default function MoveFileDialog() {
const path = useStore((state) => state.path)
const paths = useStore((state) => state.paths)
const moveFile = useStore((state) => state.moveFile)
const updateState = useStore((state) => state.updateState)
if (!path) return null
if (!paths || paths.length > 1) return null
return (
<InputDialog
open={true}
value={path}
value={paths[0]}
title="Move File"
label="Move"
Icon={CopyAllIcon}
placholder="Enter a path"
description={`You are moving "${path}". Enter destination:`}
description={`You are moving "${paths[0]}". Enter destination:`}
onCancel={() => updateState({ dialog: undefined })}
onConfirm={async (toPath) => {
await moveFile(path, toPath)
await moveFile(paths[0], toPath)
updateState({ dialog: undefined })
}}
/>
Expand Down
10 changes: 5 additions & 5 deletions client/components/Application/Dialogs/MoveFolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import InputDialog from '../../Parts/Dialogs/Input'
import { useStore } from '../store'

export default function MoveFolderDialog() {
const path = useStore((state) => state.path)
const paths = useStore((state) => state.paths)
const moveFolder = useStore((state) => state.moveFolder)
const updateState = useStore((state) => state.updateState)
if (!path) return null
if (!paths || paths.length > 1) return null
return (
<InputDialog
open={true}
value={path}
value={paths[0]}
title="Move Folder"
label="Move"
Icon={CopyAllIcon}
placholder="Enter a path"
description={`You are moving "${path}". Enter destination:`}
description={`You are moving "${paths[0]}". Enter destination:`}
onCancel={() => updateState({ dialog: undefined })}
onConfirm={async (toPath) => {
await moveFolder(path, toPath)
await moveFolder(paths[0], toPath)
updateState({ dialog: undefined })
}}
/>
Expand Down
8 changes: 5 additions & 3 deletions client/components/Application/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ export function makeStore(props: ApplicationProps) {
await loadFiles()
await selectFile(paths)
},
copyFile: async (path, toPath) => {
copyFile: async (paths, toPath) => {
const { client, onFileCreate } = get()
const result = await client.fileCopy({ path, toPath, deduplicate: true })
onFileCreate([result.path])
for (const path of paths) {
const result = await client.fileCopy({ path, toPath, deduplicate: true })
onFileCreate([result.path])
}
},
deleteFile: async (paths) => {
const { client, onFileDelete } = get()
Expand Down

0 comments on commit 2b23a80

Please sign in to comment.