Automatically select added files (#4325)

# Description of Changes
When adding files, the user probably wants to use them straight away in
the next tool that they use, so automatically select any added files (in
addition to whatever they previously had selected).
This commit is contained in:
James Brunton
2025-08-29 16:39:19 +01:00
committed by GitHub
parent eecc410b77
commit 3b28b398d9
4 changed files with 34 additions and 10 deletions
+8 -2
View File
@@ -88,6 +88,12 @@ interface AddFileOptions {
insertAfterPageId?: string;
}
export interface AddedFile {
file: File;
id: FileId;
thumbnail?: string;
}
/**
* Unified file addition helper - replaces addFiles/addProcessedFiles/addStoredFiles
*/
@@ -98,13 +104,13 @@ export async function addFiles(
filesRef: React.MutableRefObject<Map<FileId, File>>,
dispatch: React.Dispatch<FileContextAction>,
lifecycleManager: FileLifecycleManager
): Promise<Array<{ file: File; id: FileId; thumbnail?: string }>> {
): Promise<AddedFile[]> {
// Acquire mutex to prevent race conditions
await addFilesMutex.lock();
try {
const fileRecords: FileRecord[] = [];
const addedFiles: Array<{ file: File; id: FileId; thumbnail?: string }> = [];
const addedFiles: AddedFile[] = [];
// Build quickKey lookup from existing files for deduplication
const existingQuickKeys = buildQuickKeySet(stateRef.current.files.byId);