Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 28cba7f

Browse files
committedFeb 8, 2020
device remove duplicate item
1 parent 78546dc commit 28cba7f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎src/reducers/lookup.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function onGetTypesDone(state, { payload, error }) {
2323
return { ...state, loadingTypesError: true };
2424
}
2525

26-
const types = _.map(payload.sort(), v => ({
26+
const types = _.map(_.uniq(payload.sort()), v => ({
2727
key: v,
2828
name: v,
2929
}));
@@ -59,7 +59,7 @@ function onGetManufacturersDone(state, { payload, error }) {
5959
return { ...state, loadingManufacturersError: true };
6060
}
6161

62-
const manufacturers = _.map(payload.sort(), v => ({
62+
const manufacturers = _.map(_.uniq(payload.sort()), v => ({
6363
key: v,
6464
name: v,
6565
}));
@@ -99,11 +99,14 @@ function onGetModelsDone(state, { payload, error }) {
9999
return { ...state, loadingModelsError: true, isModelsLoading: false };
100100
}
101101

102-
let models = _.orderBy(payload, ['model'], ['asc']);
102+
let models = payload;
103103

104104
if (state.modelPage > 1) {
105105
models = [...state.models, ...models];
106106
}
107+
models = _.orderBy(models, ['model'], ['asc']);
108+
models = _.uniqBy(models, m => m.name);
109+
107110
return ({
108111
...state,
109112
loadingModelsError: false,
@@ -138,11 +141,13 @@ function onGetOsesDone(state, { payload, error }) {
138141
return { ...state, loadingOsesError: true, isOsesLoading: false };
139142
}
140143

141-
let oses = _.orderBy(payload, ['operatingSystem'], ['asc']);
144+
let oses = payload;
142145
if (state.osPage > 1) {
143146
oses = [...state.oses, ...oses];
144147
}
148+
oses = _.orderBy(payload, ['operatingSystem'], ['asc']);
145149

150+
oses = _.uniqBy(oses, m => m.name);
146151
return ({
147152
...state,
148153
loadingOsesError: false,

0 commit comments

Comments
 (0)
Please sign in to comment.