Skip to content

Commit

Permalink
fix: Remove non-null assertions in dataset page hook (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
bchu1 authored Jan 9, 2025
1 parent 2087cf6 commit 8d258b7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions frontend/packages/data-portal/app/hooks/useDatasetById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useTypedLoaderData } from 'remix-typedjson'

import { GetDatasetByIdQuery } from 'app/__generated__/graphql'
import { GetDatasetByIdV2Query } from 'app/__generated_v2__/graphql'
import { isDefined } from 'app/utils/nullish'

export function useDatasetById() {
const { v1, v2 } = useTypedLoaderData<{
Expand All @@ -13,13 +14,15 @@ export function useDatasetById() {

const deposition = v2.depositions[0]

const objectNames = v2.annotationsAggregate.aggregate!.map(
(aggregate) => aggregate.groupBy!.objectName!,
)
const objectNames =
v2.annotationsAggregate.aggregate
?.map((aggregate) => aggregate.groupBy?.objectName)
.filter(isDefined) ?? []

const objectShapeTypes = v2.annotationShapesAggregate.aggregate!.map(
(aggregate) => aggregate.groupBy!.shapeType!,
)
const objectShapeTypes =
v2.annotationShapesAggregate.aggregate
?.map((aggregate) => aggregate.groupBy?.shapeType)
.filter(isDefined) ?? []

return {
dataset,
Expand Down

0 comments on commit 8d258b7

Please sign in to comment.