Commit 0d086448 authored by NataliaTepluhina's avatar NataliaTepluhina

Replaced includes with some

parent fa24a09c
...@@ -34,12 +34,11 @@ export default { ...@@ -34,12 +34,11 @@ export default {
// Iterate over every label and add a `set` prop // Iterate over every label and add a `set` prop
// to determine whether it is already a part of // to determine whether it is already a part of
// selectedLabels array. // selectedLabels array.
const selectedLabelIds = state.selectedLabels.map((label) => label.id);
state.labelsFetchInProgress = false; state.labelsFetchInProgress = false;
state.labelsFetched = true; state.labelsFetched = true;
state.labels = labels.map((label) => ({ state.labels = labels.map((label) => ({
...label, ...label,
set: selectedLabelIds.includes(label.id), set: state.selectedLabels.some((selectedLabel) => selectedLabel.id === label.id),
})); }));
}, },
[types.RECEIVE_SET_LABELS_FAILURE](state) { [types.RECEIVE_SET_LABELS_FAILURE](state) {
...@@ -79,10 +78,9 @@ export default { ...@@ -79,10 +78,9 @@ export default {
}, },
[types.UPDATE_LABELS_SET_STATE](state) { [types.UPDATE_LABELS_SET_STATE](state) {
const selectedLabelIds = state.selectedLabels.map((label) => label.id);
state.labels = state.labels.map((label) => ({ state.labels = state.labels.map((label) => ({
...label, ...label,
set: selectedLabelIds.includes(label.id), set: state.selectedLabels.some((selectedLabel) => selectedLabel.id === label.id),
})); }));
}, },
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment