Skip to content

Fix DOWNLOAD_COMPLETE reducer clearing all downloads instead of the completed one#2564

Open
Valyrian-Code wants to merge 2 commits into
GeoNode:masterfrom
Valyrian-Code:fix/download-complete-reducer
Open

Fix DOWNLOAD_COMPLETE reducer clearing all downloads instead of the completed one#2564
Valyrian-Code wants to merge 2 commits into
GeoNode:masterfrom
Valyrian-Code:fix/download-complete-reducer

Conversation

@Valyrian-Code

Copy link
Copy Markdown

Problem

In reducers/resourceservice.js, the DOWNLOAD_COMPLETE case filters:

downloads: [
    ...state.downloads.filter((download) =>
        (download?.resource?.pk === action?.resource?.pk))
]

But downloads stores bare resource objects ({ pk, ... }), not { resource } wrappers:

  • DOWNLOAD_RESOURCE pushes action.resource directly;
  • the epic dispatches downloadComplete({ ...downloaded.resource }) (epics/resourceservice.js);
  • the processingDownload selector matches download?.pk;
  • the selector test fixture is downloads: [{ pk: 1 }].

So download?.resource?.pk is always undefined, the predicate becomes undefined === 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

...state.downloads.filter((download) =>
    download?.pk !== action?.resource?.pk)

Test

New reducers/__tests__/resourceservice-test.js. The DOWNLOAD_COMPLETE case fails on master (returns downloads: []) and passes with the fix (returns downloads: [{ pk: 2 }]). Full unit suite stays green (Node 20).

… 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}]).
Copilot AI review requested due to automatic review settings June 11, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread geonode_mapstore_client/client/js/reducers/resourceservice.js Outdated
Per review: Array.prototype.filter already returns a new array, so the
surrounding [ ...filter(...) ] spread is unnecessary.
@Valyrian-Code

Copy link
Copy Markdown
Author

Good call — dropped the redundant spread; filter already returns a new array. Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants