Skip to content

Commit 357c942

Browse files
committed
feat: interval
1 parent d5c2fe6 commit 357c942

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

apps/frontend/src/components/launches/calendar.tsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
'use client';
22

3-
import React, { FC, Fragment, useCallback, useMemo } from 'react';
3+
import React, {
4+
FC,
5+
Fragment,
6+
useCallback,
7+
useEffect,
8+
useMemo,
9+
useState,
10+
} from 'react';
411
import {
512
CalendarContext,
613
Integrations,
@@ -23,11 +30,12 @@ import { IntegrationContext } from '@gitroom/frontend/components/launches/helper
2330
import { PreviewPopup } from '@gitroom/frontend/components/marketplace/special.message';
2431
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
2532
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
26-
import { groupBy, sortBy } from 'lodash';
33+
import { groupBy, random, sortBy } from 'lodash';
2734
import Image from 'next/image';
2835
import { extend } from 'dayjs';
2936
import { isUSCitizen } from './helpers/isuscitizen.utils';
3037
import removeMd from 'remove-markdown';
38+
import { useInterval } from '@mantine/hooks';
3139
extend(isSameOrAfter);
3240
extend(isSameOrBefore);
3341

@@ -258,6 +266,8 @@ export const CalendarColumn: FC<{
258266
randomHour?: boolean;
259267
}> = (props) => {
260268
const { getDate, randomHour } = props;
269+
const [num, setNum] = useState(0);
270+
261271
const user = useUser();
262272
const {
263273
integrations,
@@ -299,7 +309,22 @@ export const CalendarColumn: FC<{
299309

300310
const isBeforeNow = useMemo(() => {
301311
return getDate.startOf('hour').isBefore(dayjs().startOf('hour'));
302-
}, [getDate]);
312+
}, [getDate, num]);
313+
314+
const { start, stop } = useInterval(useCallback(() => {
315+
if (isBeforeNow) {
316+
return ;
317+
}
318+
setNum(num + 1);
319+
}, [isBeforeNow]), random(120000, 150000));
320+
321+
useEffect(() => {
322+
start();
323+
324+
return () => {
325+
stop();
326+
};
327+
}, []);
303328

304329
const [{ canDrop }, drop] = useDrop(() => ({
305330
accept: 'post',

0 commit comments

Comments
 (0)