Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(selection): remove unused SelectionArray methods #3485

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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