From 1d7893dca899fbcec44c82f049a9c10a085f7153 Mon Sep 17 00:00:00 2001
From: skjnldsv <skjnldsv@protonmail.com>
Date: Fri, 10 May 2024 13:57:03 +0200
Subject: fix(files): do not rely on unique fileid

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
---
 .../src/components/FileEntry/FileEntryCheckbox.vue      | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

(limited to 'apps/files/src/components/FileEntry/FileEntryCheckbox.vue')

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)
-- 
cgit v1.2.3

