Skip to content

Commit

Permalink
feat: add hook constraint to trigger only for past dates, removed the…
Browse files Browse the repository at this point in the history
… ten min offset
  • Loading branch information
ElRodrigote committed Jul 8, 2024
1 parent 5c212d5 commit 8ac399b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/app/components/stackbox/Stackbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ interface SelectTokenButtonProps {
onAnimationEnd: AnimationEventHandler<HTMLElement>;
}
const ONE_MINUTE = 1;
const TEN_MINUTES = 10;
const ONE_MINUTE_IN_MS = 60000;

const frequencyOptions = [
Expand Down Expand Up @@ -196,8 +195,11 @@ export const Stackbox = () => {
*/
useEffect(() => {
function oneMinuteInterval() {
setStartDateTime(getDatePlusMinsOffset(startDateTime, TEN_MINUTES));
setEndDateTime(getDatePlusMinsOffset(endDateTime, TEN_MINUTES));
const startDateInThePast = startDateTime.getTime() <= Date.now();
if (startDateInThePast) {
setStartDateTime(getDatePlusMinsOffset(startDateTime, ONE_MINUTE));
setEndDateTime(getDatePlusMinsOffset(endDateTime, ONE_MINUTE));
}
}

oneMinuteInterval();
Expand Down Expand Up @@ -607,7 +609,7 @@ export const Stackbox = () => {
frequency={frequency}
startTime={
isPastStartDate
? new Date(getDatePlusMinsOffset(new Date(), TEN_MINUTES))
? new Date(getDatePlusMinsOffset(new Date(), ONE_MINUTE))
: startDateTime
}
endTime={endDateTime}
Expand Down

0 comments on commit 8ac399b

Please sign in to comment.