delete multiple files with selection
This commit is contained in:
17
frontend/utils/selection.ts
Normal file
17
frontend/utils/selection.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { DirectoryEntry } from '~/shared/types';
|
||||
|
||||
/** Converts a selection and the entry that triggered an action into the target entries
|
||||
* @param targetEntry - The entry that triggered an action
|
||||
* @param selection - The selected entries
|
||||
* @returns If there are no selected elements or the target was not included only the target is returned. Otherwise the selection is returned
|
||||
*/
|
||||
export function getTargetsFromSelection(
|
||||
targetEntry: DirectoryEntry,
|
||||
selection: Set<DirectoryEntry>
|
||||
): DirectoryEntry[] {
|
||||
if (selection.size === 0 || !selection.has(targetEntry)) {
|
||||
return [targetEntry];
|
||||
}
|
||||
|
||||
return Array.from(selection);
|
||||
}
|
||||
Reference in New Issue
Block a user