Skip to content

Commit bbfe791

Browse files
Crash--claude
andcommitted
fix: RESOLVE_FOLDER_ITEMS appends new items for DropzoneDnD folder drops
When dropping a folder via DropzoneDnD, directory entries have file=null so buildPreliminaryItems filters them out. flattenEntries then discovers the actual files inside. The RESOLVE_FOLDER_ITEMS reducer now appends items whose fileId doesn't exist in the queue yet, instead of only updating existing ones. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6fb1de6 commit bbfe791

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

src/modules/upload/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,18 @@ export const queue = (state = [], action) => {
156156
return []
157157
case RESOLVE_FOLDER_ITEMS: {
158158
const resolved = action.resolvedItems
159-
return state.map(i => {
159+
const existingIds = new Set(state.map(i => i.fileId))
160+
// Update existing items + append new ones (DropzoneDnD: directory
161+
// entries have file=null so buildPreliminaryItems filters them out,
162+
// flattenEntries discovers the actual files inside)
163+
const updated = state.map(i => {
160164
const update = resolved.find(r => r.fileId === i.fileId)
161165
return update ? { ...i, ...update } : i
162166
})
167+
const newItems = resolved
168+
.filter(r => !existingIds.has(r.fileId))
169+
.map(r => itemInitialState(r))
170+
return [...updated, ...newItems]
163171
}
164172
case UPLOAD_FILE:
165173
case RECEIVE_UPLOAD_SUCCESS:

src/modules/upload/index.spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,39 @@ describe('queue reducer', () => {
368368
expect(result).toEqual([])
369369
})
370370

371+
it('should update existing items and append new ones on RESOLVE_FOLDER_ITEMS', () => {
372+
const initialState = [
373+
{
374+
fileId: 'report.pdf',
375+
status: 'pending',
376+
file: { name: 'report.pdf' },
377+
progress: null
378+
}
379+
]
380+
const action = {
381+
type: 'RESOLVE_FOLDER_ITEMS',
382+
resolvedItems: [
383+
{
384+
fileId: 'report.pdf',
385+
file: { name: 'report.pdf' },
386+
folderId: 'resolved-dir',
387+
relativePath: null
388+
},
389+
{
390+
fileId: 'photos/img.jpg',
391+
file: { name: 'img.jpg' },
392+
folderId: 'photos-dir',
393+
relativePath: 'photos/img.jpg'
394+
}
395+
]
396+
}
397+
const result = queue(initialState, action)
398+
expect(result).toHaveLength(2)
399+
expect(result[0].folderId).toBe('resolved-dir')
400+
expect(result[1].fileId).toBe('photos/img.jpg')
401+
expect(result[1].status).toBe('pending')
402+
})
403+
371404
it('should handle PURGE_UPLOAD_QUEUE action type', () => {
372405
const action = {
373406
type: 'PURGE_UPLOAD_QUEUE'

0 commit comments

Comments
 (0)