Skip to content

Commit

Permalink
Revert "Préavis - Limite la fréquence des appels API après changement…
Browse files Browse the repository at this point in the history
… de filtre dans la liste (#3780)"

This reverts commit 8fdc5c1, reversing
changes made to ea0324b.
  • Loading branch information
ivangabriele committed Oct 22, 2024
1 parent bc2a697 commit f05f602
Showing 1 changed file with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import { isLegacyFirefox } from '@utils/isLegacyFirefox'
import { useIsSuperUser } from 'auth/hooks/useIsSuperUser'
import { useCallback, useEffect, useRef, useState } from 'react'
import styled, { css } from 'styled-components'
import { useDebounce } from 'use-debounce'

import { getTableColumns } from './columns'
import { DEFAULT_PAGE_SIZE, ExpectedArrivalPeriod, SUB_MENUS_AS_OPTIONS } from './constants'
import { DEFAULT_PAGE_SIZE, SUB_MENUS_AS_OPTIONS } from './constants'
import { FilterBar } from './FilterBar'
import { FilterTags } from './FilterTags'
import { Row } from './Row'
Expand Down Expand Up @@ -69,26 +68,16 @@ export function PriorNotificationList({ isFromUrl }: PriorNotificationListProps)
BackendApi.SortDirection.DESC
)

const [rtkQueryParams] = useDebounce(
{
apiPaginationParams,
apiSortingParams,
listFilter
},
1000
)
const areRtkQueryParamsValid = !(
rtkQueryParams.listFilter.expectedArrivalPeriod === ExpectedArrivalPeriod.CUSTOM &&
!rtkQueryParams.listFilter.expectedArrivalCustomPeriod
)
const rtkQueryParams = {
apiPaginationParams,
apiSortingParams,
listFilter
}
// `!!error` !== `isError` because `isError` is `false` when the query is fetching.
const { data, error, isError, isFetching } = useGetPriorNotificationsQuery(
areRtkQueryParamsValid ? rtkQueryParams : skipToken,
{
...RTK_ONE_MINUTE_POLLING_QUERY_OPTIONS,
...RTK_FORCE_REFETCH_QUERY_OPTIONS
}
)
const { data, error, isError, isFetching } = useGetPriorNotificationsQuery(rtkQueryParams, {
...RTK_ONE_MINUTE_POLLING_QUERY_OPTIONS,
...RTK_FORCE_REFETCH_QUERY_OPTIONS
})
useHandleFrontendApiError(
DisplayedErrorKey.SIDE_WINDOW_PRIOR_NOTIFICATION_LIST_ERROR,
error,
Expand Down

0 comments on commit f05f602

Please sign in to comment.