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' ;
411import {
512 CalendarContext ,
613 Integrations ,
@@ -23,11 +30,12 @@ import { IntegrationContext } from '@gitroom/frontend/components/launches/helper
2330import { PreviewPopup } from '@gitroom/frontend/components/marketplace/special.message' ;
2431import isSameOrAfter from 'dayjs/plugin/isSameOrAfter' ;
2532import isSameOrBefore from 'dayjs/plugin/isSameOrBefore' ;
26- import { groupBy , sortBy } from 'lodash' ;
33+ import { groupBy , random , sortBy } from 'lodash' ;
2734import Image from 'next/image' ;
2835import { extend } from 'dayjs' ;
2936import { isUSCitizen } from './helpers/isuscitizen.utils' ;
3037import removeMd from 'remove-markdown' ;
38+ import { useInterval } from '@mantine/hooks' ;
3139extend ( isSameOrAfter ) ;
3240extend ( 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