diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-05-10 13:57:03 +0200 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2024-06-12 17:15:51 +0200 |
commit | 1d7893dca899fbcec44c82f049a9c10a085f7153 (patch) | |
tree | b9d51ab0fd2db7b15b7e69d19acdac77fc6cc6e1 /apps/files/src/components/FileEntry/FileEntryCheckbox.vue | |
parent | 6ec6c1fe4fbebd5c811c45600d79e1835da4b1c2 (diff) | |
download | nextcloud-server-1d7893dca899fbcec44c82f049a9c10a085f7153.tar.gz nextcloud-server-1d7893dca899fbcec44c82f049a9c10a085f7153.zip |
fix(files): do not rely on unique fileid
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/src/components/FileEntry/FileEntryCheckbox.vue')
-rw-r--r-- | apps/files/src/components/FileEntry/FileEntryCheckbox.vue | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/apps/files/src/components/FileEntry/FileEntryCheckbox.vue b/apps/files/src/components/FileEntry/FileEntryCheckbox.vue index edb94e65f27..987b48ef8ae 100644 --- a/apps/files/src/components/FileEntry/FileEntryCheckbox.vue +++ b/apps/files/src/components/FileEntry/FileEntryCheckbox.vue @@ -24,6 +24,7 @@ import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' import { useKeyboardStore } from '../../store/keyboard.ts' import { useSelectionStore } from '../../store/selection.ts' import logger from '../../logger.js' +import type { FileSource } from '../../types.ts' export default defineComponent({ name: 'FileEntryCheckbox', @@ -66,10 +67,10 @@ export default defineComponent({ return this.selectionStore.selected }, isSelected() { - return this.selectedFiles.includes(this.fileid) + return this.selectedFiles.includes(this.source.source) }, index() { - return this.nodes.findIndex((node: Node) => node.fileid === this.fileid) + return this.nodes.findIndex((node: Node) => node.source === this.source.source) }, isFile() { return this.source.type === FileType.File @@ -88,20 +89,20 @@ export default defineComponent({ // Get the last selected and select all files in between if (this.keyboardStore?.shiftKey && lastSelectedIndex !== null) { - const isAlreadySelected = this.selectedFiles.includes(this.fileid) + const isAlreadySelected = this.selectedFiles.includes(this.source.source) const start = Math.min(newSelectedIndex, lastSelectedIndex) const end = Math.max(lastSelectedIndex, newSelectedIndex) const lastSelection = this.selectionStore.lastSelection const filesToSelect = this.nodes - .map(file => file.fileid) + .map(file => file.source) .slice(start, end + 1) - .filter(Boolean) as number[] + .filter(Boolean) as FileSource[] // If already selected, update the new selection _without_ the current file const selection = [...lastSelection, ...filesToSelect] - .filter(fileid => !isAlreadySelected || fileid !== this.fileid) + .filter(source => !isAlreadySelected || source !== this.source.source) logger.debug('Shift key pressed, selecting all files in between', { start, end, filesToSelect, isAlreadySelected }) // Keep previous lastSelectedIndex to be use for further shift selections @@ -110,8 +111,8 @@ export default defineComponent({ } const selection = selected - ? [...this.selectedFiles, this.fileid] - : this.selectedFiles.filter(fileid => fileid !== this.fileid) + ? [...this.selectedFiles, this.source.source] + : this.selectedFiles.filter(source => source !== this.source.source) logger.debug('Updating selection', { selection }) this.selectionStore.set(selection) |