Skip to content
This repository has been archived by the owner on Jan 27, 2020. It is now read-only.

fixing bug when id is array of string all #349

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/features/Gw2/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function generateActions (resourceName, getResource, afterGet) {
// We filter them, then pass them along to the service (for example lib/gw2/readCalculatedItemStats)
// If calculatedId exists, use that.
const actualId = +(typeof id === 'object' ? (id.calculatedId || id.id) : id);
const isValidId = actualId && actualId !== -1;
const isValidId = (id === 'all') || (actualId && actualId !== -1);
Copy link
Owner

@itsdouges itsdouges Oct 8, 2017

Choose a reason for hiding this comment

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

(thanks for your first contribution! :))

is this really needed though? the current logic actualId && actualId !== -1 would return true for the string 'all'.

> 'all' && 'all' !== -1
true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actualId was not 'all', it was NaN. Maybe because of the + right after the assignment equals?

Copy link
Owner

Choose a reason for hiding this comment

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

ah, good catch. that'll do it.

can you add a test case for this pls? the reducer/action logic is pretty well tested (compared to the rest of the code base.. haha)

const isNotInStore = !store[resourceName][actualId] || !!store[resourceName][actualId].error;
return isValidId && isNotInStore;
}));
Expand Down