Skip to content

Commit

Permalink
[fix] effects: prevent time reset with invalid valese (#2441)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta committed Nov 17, 2023
1 parent 3ca8df0 commit f70b20e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/src/effects/effect-time-configurator.tsx
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

0 comments on commit f70b20e

Please sign in to comment.