Skip to content

Commit

Permalink
fix(featuresList): sort in feature.service
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Mar 7, 2018
1 parent ccf19c1 commit 54a685d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/lib/feature/shared/feature-group.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export class FeatureGroupPipe implements PipeTransform {
groupedFeatures[source].push(feature);
});

const sourceFeatures = Object.keys(groupedFeatures).sort((a, b) => {
return groupedFeatures[a][0].order - groupedFeatures[b][0].order;
}).map(
const sourceFeatures = Object.keys(groupedFeatures).map(
(source: string) => [source, groupedFeatures[source]]
);

Expand Down
8 changes: 6 additions & 2 deletions src/lib/feature/shared/feature.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class FeatureService {
constructor() { }

setFeatures(features: Feature[]) {
this.features$.next(features);
this.features$.next(features.sort(this.sortFeatures));
}

updateFeatures(features: Feature[], source: string, sourcesToKeep?: string[]) {
Expand All @@ -23,7 +23,8 @@ export class FeatureService {
return feature.source !== source &&
(!sourcesToKeep || sourcesToKeep.includes(feature.source));
})
.concat(features);
.concat(features)
.sort(this.sortFeatures);

this.features$.next(features_);
}
Expand Down Expand Up @@ -61,4 +62,7 @@ export class FeatureService {
return feature1.id === feature2.id && feature1.source === feature2.source;
}

private sortFeatures(feature1, feature2) {
return feature1.order - feature2.order;
}
}

0 comments on commit 54a685d

Please sign in to comment.