Fix DOWNLOAD_COMPLETE reducer clearing all downloads instead of the completed one#2564
Open
Valyrian-Code wants to merge 2 commits into
Open
Fix DOWNLOAD_COMPLETE reducer clearing all downloads instead of the completed one#2564Valyrian-Code wants to merge 2 commits into
Valyrian-Code wants to merge 2 commits into
Conversation
… one
The DOWNLOAD_COMPLETE case filtered downloads on download?.resource?.pk,
but downloads store bare resource objects ({pk}), so that path is always
undefined and the === predicate emptied the whole array — completing one
download cleared the in-progress state of all others. Filter on
download?.pk !== action?.resource?.pk instead (keep all but the completed).
Adds reducers/__tests__/resourceservice-test.js; the case fails on master
(downloads: []) and passes with the fix (downloads: [{pk:2}]).
There was a problem hiding this comment.
Code Review
This pull request adds unit tests for the resourceservice reducer and corrects the logic for removing completed downloads in resourceservice.js. The feedback suggests a minor optimization to remove a redundant spread operator when filtering the downloads array.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Per review: Array.prototype.filter already returns a new array, so the surrounding [ ...filter(...) ] spread is unnecessary.
Author
|
Good call — dropped the redundant spread; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
reducers/resourceservice.js, theDOWNLOAD_COMPLETEcase filters:But
downloadsstores bare resource objects ({ pk, ... }), not{ resource }wrappers:DOWNLOAD_RESOURCEpushesaction.resourcedirectly;downloadComplete({ ...downloaded.resource })(epics/resourceservice.js);processingDownloadselector matchesdownload?.pk;downloads: [{ pk: 1 }].So
download?.resource?.pkis alwaysundefined, the predicate becomesundefined === action.resource.pk(false for every element), and the entire downloads array is emptied — completing one download clears the "in progress" state of all the others. The operator is also inverted: to drop the completed one, the filter must keep the entries that do not match.Fix
Test
New
reducers/__tests__/resourceservice-test.js. TheDOWNLOAD_COMPLETEcase fails onmaster(returnsdownloads: []) and passes with the fix (returnsdownloads: [{ pk: 2 }]). Full unit suite stays green (Node 20).