Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(change-requests): prevent incorrect scheduled changes warning #3593

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/web/components/ExistingChangeRequestAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from 'react'
import { FC, useRef } from 'react';
import { useGetChangeRequestsQuery } from 'common/services/useChangeRequest'
import WarningMessage from './WarningMessage'
import moment from 'moment'
Expand All @@ -19,10 +19,11 @@ const ExistingChangeRequestAlert: FC<ExistingChangeRequestAlertType> = ({
environmentId,
feature_id: featureId,
})
const date = useRef(moment().toISOString())
const { data: scheduledChangeRequests } = useGetChangeRequestsQuery({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that it was necessary (thanks to an assist from @kyle-ssg) to move this out to useRef to avoid an infinite recursion caused by the date being calculated on each re-render.

environmentId,
feature_id: featureId,
live_from_after: moment().startOf('hour').toISOString(),
live_from_after: date.current,
})

if (scheduledChangeRequests?.results?.length) {
Expand Down
Loading