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] effects: prevent time reset with invalid values #2441

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/src/effects/effect-time-configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ export default function EffectTimeConfiguratorFactory(

const setDate = useCallback(
newDate => {
if (!newDate) return;

const newFormattedDate = moment(newDate).format('YYYY-MM-DD');
const newTimestamp = getTimestamp(newFormattedDate, formattedTime, timezone);
onTimeParametersChanged({timestamp: newTimestamp});
Expand All @@ -252,6 +254,8 @@ export default function EffectTimeConfiguratorFactory(

const setTime = useCallback(
newTime => {
if (!newTime) return;

const newTimestamp = getTimestamp(formattedDate, newTime, timezone);
onTimeParametersChanged({timestamp: newTimestamp});
},
Expand All @@ -260,6 +264,8 @@ export default function EffectTimeConfiguratorFactory(

const setTimezone = useCallback(
newTimezone => {
if (!newTimezone) return;

const newTimestamp = getTimestamp(formattedDate, formattedTime, newTimezone);
// date and time are adjusted to have the same value but in the new timezone
onTimeParametersChanged({timestamp: newTimestamp, timezone: newTimezone});
Expand Down