Skip to content

Commit 2bf3500

Browse files
authored
Merge pull request #23732 from opf/code-maintenance/OP-19544-remove-lodash-set-dedup
[OP-19544] Replace lodash set/dedup helpers with native
2 parents 715b54a + a39f377 commit 2bf3500

30 files changed

Lines changed: 66 additions & 50 deletions

File tree

frontend/src/app/core/apiv3/endpoints/relations/apiv3-relations-paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class ApiV3RelationsPaths extends ApiV3ResourceCollection<RelationResourc
5757
const chunks = chunk(workPackageIds, MAGIC_RELATION_SIZE);
5858
return forkJoin(chunks.map((chunk) => this.loadInvolved(chunk)))
5959
.pipe(
60-
map((results) => _.flatten(results)),
60+
map((results) => results.flat()),
6161
);
6262
}
6363

frontend/src/app/core/apiv3/endpoints/work_packages/api-v3-work-packages-paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ApiV3WorkPackagesPaths extends ApiV3Collection<WorkPackageResource,
7070

7171
return new Promise<undefined>((resolve, reject) => {
7272
this
73-
.loadCollectionsFor(_.uniq(ids))
73+
.loadCollectionsFor(Array.from(new Set(ids)))
7474
.then((pagedResults:WorkPackageCollectionResource[]) => {
7575
pagedResults.forEach((results) => {
7676
if (results.schemas) {

frontend/src/app/features/hal/resources/error-resource.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,20 @@ export class ErrorResource extends HalResource {
9494
}
9595

9696
public getInvolvedAttributes():string[] {
97-
let columns = [];
97+
let columns:ErrorResource[] = [];
9898

9999
if (this.details) {
100-
columns = [{ details: this.details }];
100+
columns = [{ details: this.details as { attribute:string } } as ErrorResource];
101101
} else if (this.errors) {
102-
columns = this.errors;
102+
columns = this.errors as ErrorResource[];
103103
}
104104

105-
return _.flatten(columns.map((resource:ErrorResource) => {
105+
return columns.map((resource:ErrorResource):string => {
106106
if (resource.errorIdentifier === v3ErrorIdentifierMultipleErrors) {
107107
return this.extractMultiError(resource)[0];
108108
}
109-
return resource.details.attribute;
110-
}));
109+
return (resource.details as { attribute:string }).attribute;
110+
}).flat();
111111
}
112112

113113
public getMessagesPerAttribute():Record<string, string[]> {

frontend/src/app/features/hal/resources/hal-resource.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export class HalResource {
287287
*/
288288
public $embeddableKeys():string[] {
289289
const properties = Object.keys(this.$source);
290-
return _.without(properties, '_links', '_embedded', 'id');
290+
return properties.filter((property) => !['_links', '_embedded', 'id'].includes(property));
291291
}
292292

293293
/**
@@ -296,6 +296,6 @@ export class HalResource {
296296
*/
297297
public $linkableKeys():string[] {
298298
const properties = Object.keys(this.$links);
299-
return _.without(properties, 'self');
299+
return properties.filter((property) => property !== 'self');
300300
}
301301
}

frontend/src/app/features/hal/resources/project-resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ export class ProjectResource extends HalResource {
5151
* Exclude the schema _link from the linkable Resources.
5252
*/
5353
public $linkableKeys():string[] {
54-
return _.without(super.$linkableKeys(), 'schema');
54+
return super.$linkableKeys().filter((key) => key !== 'schema');
5555
}
5656
}

frontend/src/app/features/hal/resources/time-entry-resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class TimeEntryResource extends HalResource {
5656
* Exclude the schema _link from the linkable Resources.
5757
*/
5858
public $linkableKeys():string[] {
59-
return _.without(super.$linkableKeys(), 'schema');
59+
return super.$linkableKeys().filter((key) => key !== 'schema');
6060
}
6161
}
6262

frontend/src/app/features/hal/resources/work-package-resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export class WorkPackageBaseResource extends HalResource {
297297
* Exclude the schema _link from the linkable Resources.
298298
*/
299299
public $linkableKeys():string[] {
300-
return _.without(super.$linkableKeys(), 'schema');
300+
return super.$linkableKeys().filter((key) => key !== 'schema');
301301
}
302302

303303
/**

frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ export class InAppNotificationActorsLineComponent implements OnInit {
6969
})
7070
.filter((actor) => actor !== null) as PrincipalLike[];
7171

72-
this.actors = _.uniqBy(actors, (item) => item.href);
72+
this.actors = actors.filter((item, index, self) => index === self.findIndex((other) => other.href === item.href));
7373
}
7474
}

frontend/src/app/features/work-packages/components/wp-card-view/services/wp-card-drag-and-drop.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class WorkPackageCardDragAndDropService {
133133
* Update current order
134134
*/
135135
private updateOrder(newOrder:string[]) {
136-
newOrder = _.uniq(newOrder);
136+
newOrder = Array.from(new Set(newOrder));
137137

138138
Promise
139139
.all(newOrder.map((id) => this

frontend/src/app/features/work-packages/components/wp-fast-table/builders/modes/hierarchy/hierarchy-render-pass.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ export class HierarchyRenderPass extends PrimaryRenderPass {
132132
// Append all new elements
133133
elements = elements.concat(newElements);
134134
// Remove duplicates (Regression #29652)
135-
this.deferred[parent.id!] = _.uniqBy(elements, (el) => el.id!);
135+
const seen = new Set<string>();
136+
this.deferred[parent.id!] = elements.filter((el) => {
137+
if (seen.has(el.id!)) { return false; }
138+
seen.add(el.id!);
139+
return true;
140+
});
136141
return true;
137142
}
138143
// Otherwise, continue the chain upwards

0 commit comments

Comments
 (0)