Skip to content

Commit

Permalink
[Tech] move undefine function in sse.ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed Jan 20, 2025
1 parent bd6aba2 commit 0891f79
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions frontend/src/features/Mission/components/MissionForm/slice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { undefine, type ControlUnit } from '@mtes-mct/monitor-ui'
import { type ControlUnit } from '@mtes-mct/monitor-ui'
import { createSelector, createSlice, type PayloadAction } from '@reduxjs/toolkit'

import type { Infraction, Mission, NewInfraction, NewMission } from '../../../../domain/entities/missions'
Expand Down Expand Up @@ -144,7 +144,7 @@ const missionFormsSlice = createSlice({
missionForm: {
// We keep all data not received from the Mission event (see MISSION_EVENT_UNSYNCHRONIZED_PROPERTIES)
...mission.missionForm,
...undefine(action.payload)
...action.payload
} as Mission
}
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/features/Mission/components/MissionForm/sse.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { undefine } from '@mtes-mct/monitor-ui'

import { isMissionAutoUpdateEnabled } from './utils'

import type { Mission } from '../../../../domain/entities/missions'

export const missionEventListener = (callback: (mission: Mission) => void) => (event: MessageEvent) => {
const mission = JSON.parse(event.data) as Mission
const mission = undefine(JSON.parse(event.data)) as Mission

// eslint-disable-next-line no-console
console.log(`SSE: received a mission update.`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { undefine } from '@mtes-mct/monitor-ui'

import { isReportingAutoUpdateEnabled } from './utils'

import type { Reporting } from 'domain/entities/reporting'

export const reportingEventListener = (callback: (reporting: Reporting) => void) => (event: MessageEvent) => {
const reporting = JSON.parse(event.data) as Reporting
const reporting = undefine(JSON.parse(event.data)) as Reporting

// eslint-disable-next-line no-console
console.log(`SSE: received a reporting update.`)
Expand Down

0 comments on commit 0891f79

Please sign in to comment.