Skip to content

Commit

Permalink
Merge pull request #3485 from owid/selection-cleanup
Browse files Browse the repository at this point in the history
refactor(selection): remove unused SelectionArray methods
  • Loading branch information
marcelgerber authored Apr 12, 2024
2 parents cca1779 + dd6a16b commit 2d9eb0d
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions packages/@ourworldindata/grapher/src/selection/SelectionArray.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntityCode, EntityId, EntityName } from "@ourworldindata/types"
import { difference, mapBy } from "@ourworldindata/utils"
import { difference } from "@ourworldindata/utils"
import { action, computed, observable } from "mobx"

export interface Entity {
Expand Down Expand Up @@ -28,30 +28,6 @@ export class SelectionArray {
return new Set(this.availableEntityNames)
}

@computed get entityNameToIdMap(): Map<string, number | undefined> {
return mapBy(
this.availableEntities,
(e) => e.entityName,
(e) => e.entityId
)
}

@computed get entityCodeToNameMap(): Map<string | undefined, string> {
return mapBy(
this.availableEntities,
(e) => e.entityCode,
(e) => e.entityName
)
}

@computed get entityIdToNameMap(): Map<number | undefined, string> {
return mapBy(
this.availableEntities,
(e) => e.entityId,
(e) => e.entityName
)
}

@computed get hasSelection(): boolean {
return this.selectedEntityNames.length > 0
}
Expand Down Expand Up @@ -84,19 +60,6 @@ export class SelectionArray {
return this
}

@action.bound setSelectedEntitiesByCode(entityCodes: EntityCode[]): this {
const map = this.entityCodeToNameMap
const codesInData = entityCodes.filter((code) => map.has(code))
return this.setSelectedEntities(
codesInData.map((code) => map.get(code)!)
)
}

@action.bound setSelectedEntitiesByEntityId(entityIds: EntityId[]): this {
const map = this.entityIdToNameMap
return this.setSelectedEntities(entityIds.map((id) => map.get(id)!))
}

@action.bound selectAll(): this {
return this.addToSelection(this.unselectedEntityNames)
}
Expand Down

0 comments on commit 2d9eb0d

Please sign in to comment.