Skip to content

Commit

Permalink
[Tech] Réduction des appels api à l'ouverture de l'application (#1182)
Browse files Browse the repository at this point in the history
## Related Pull Requests & Issues

- Resolve #1181
- Resolve #1119


----

- [ ] Tests E2E (Cypress)
  • Loading branch information
claire2212 committed Feb 5, 2024
2 parents 2878252 + 728bd71 commit 203922c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions frontend/cypress/e2e/main_window/interest_point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ context('InterestPoint', () => {

cy.getDataCy('interest-point').click()
cy.getDataCy('dms-coordinates-input').eq(1).should('have.value', '__° __′ __″ _ ___° __′ __″ _')
cy.wait(400)
cy.get('#root').click(650, 690)
cy.getDataCy('interest-point-name-input').type('Phénomène 3')
cy.getDataCy('interest-point-observations-input').type('Est encore encore dans la bergerie')
Expand Down
1 change: 1 addition & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/src/api/missionsAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const missionsAPI = monitorenvPrivateApi.injectEndpoints({
export const publicMissionsAPI = monitorenvPublicApi.injectEndpoints({
endpoints: builder => ({
getEngagedControlUnits: builder.query<Array<ControlUnit.EngagedControlUnit>, void>({
forceRefetch: () => true,
query: () => `/v1/missions/engaged_control_units`
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export function SelectedMissionToAttachLayer({ map }: BaseMapChildrenProps) {
const { selectedMission: attachedMission } = useGetMissionsQuery(undefined, {
selectFromResult: ({ data }) => ({
selectedMission: data?.find(mission => mission.id === missionId && !editedReporting?.detachedFromMissionAtUtc)
})
}),
skip: !missionId
})
const selectedAttachedMissionVectorSourceRef = useRef(new VectorSource()) as MutableRefObject<VectorSource>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ export function MissionToAttachLayer({ map, mapClickEvent }: BaseMapChildrenProp
state => state.attachMissionToReporting.isMissionAttachmentInProgress
)

const { data: missions } = useGetMissionsQuery({
missionStatus: [MissionStatusEnum.PENDING],
startedAfterDateTime: customDayjs.utc().startOf('day').utc().subtract(90, 'day').toISOString()
})
const { data: missions } = useGetMissionsQuery(
{
missionStatus: [MissionStatusEnum.PENDING],
startedAfterDateTime: customDayjs.utc().startOf('day').subtract(90, 'day').toISOString()
},
{ skip: !isMissionAttachmentInProgress }
)

const missionsMultiPolygons = useMemo(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export function SelectedMissionLayer({ map }: BaseMapChildrenProps) {
const { selectedMission } = useGetMissionsQuery(undefined, {
selectFromResult: ({ data }) => ({
selectedMission: data?.find(op => op.id === selectedMissionIdOnMap)
})
}),
skip: !selectedMissionIdOnMap
})

const hasNoMissionDuplication = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ export function ReportingToAttachLayer({ map, mapClickEvent }: BaseMapChildrenPr
)
const attachedReportings = useAppSelector(state => state.attachReportingToMission.attachedReportings)

const { data: reportings } = useGetReportingsQuery({
status: [StatusFilterEnum.IN_PROGRESS]
})
const { data: reportings } = useGetReportingsQuery(
{
status: [StatusFilterEnum.IN_PROGRESS]
},
{ skip: !isReportingAttachmentInProgress }
)

const attachedReportingsFeatures = useMemo(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export function ControlUnitSelector({ controlUnitIndex, removeControlUnit }: Con
}

const { data: engagedControlUnits = [] } = useGetEngagedControlUnitsQuery(undefined, {
...RTK_DEFAULT_QUERY_OPTIONS,
skip: !missionIsNewMission
})

Expand Down

0 comments on commit 203922c

Please sign in to comment.