Skip to content

Commit

Permalink
Remove noise_sensor event type assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Jul 11, 2024
1 parent f980e51 commit 3f4de98
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/lib/ui/noise-sensor/NoiseSensorEventItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import { DateTime } from 'luxon'

import { ClockIcon } from 'lib/icons/Clock.js'

type NoiseSensorNoiseThresholdTriggeredEvent = Extract<
SeamEvent,
{ event_type: 'noise_sensor.noise_threshold_triggered' }
>

interface NoiseSensorEventItemProps {
event: SeamEvent
event: NoiseSensorNoiseThresholdTriggeredEvent
}

export function NoiseSensorEventItem({
Expand Down Expand Up @@ -40,16 +45,15 @@ export function NoiseSensorEventItem({
)
}

const getContextSublabel = (event: SeamEvent): string | null => {
if ('noise_threshold_name' in event) {
// @ts-expect-error UPSTREAM: Shallow event type
// https://github.com/seamapi/react/issues/611
const getContextSublabel = (
event: NoiseSensorNoiseThresholdTriggeredEvent
): string | null => {
if (event.noise_threshold_name != null) {
return event.noise_threshold_name
}

if ('noise_level_decibels' in event) {
// UPSTREAM: Shallow event types.
return `${event.noise_level_decibels as string} ${t.decibel}`
if (event.noise_level_decibels != null) {
return `${event.noise_level_decibels} ${t.decibel}`
}

return null
Expand Down

0 comments on commit 3f4de98

Please sign in to comment.