import type { FC } from 'react'; import { useEffect, useRef } from 'react'; import { ExternalLink } from 'react-external-link'; import { CopyToClipboardIcon } from '../../../src/utils/CopyToClipboardIcon'; import { Time } from '../../../src/utils/dates/Time'; import type { TimeoutToggle } from '../../../src/utils/helpers/hooks'; import type { ColorGenerator } from '../../../src/utils/services/ColorGenerator'; import { useSetting } from '../../utils/settings'; import type { ShortUrl } from '../data'; import { useShortUrlsQuery } from './hooks'; import type { ShortUrlsRowMenuType } from './ShortUrlsRowMenu'; import { ShortUrlStatus } from './ShortUrlStatus'; import { ShortUrlVisitsCount } from './ShortUrlVisitsCount'; import { Tags } from './Tags'; import './ShortUrlsRow.scss'; interface ShortUrlsRowProps { onTagClick?: (tag: string) => void; shortUrl: ShortUrl; } export type ShortUrlsRowType = FC; export const ShortUrlsRow = ( ShortUrlsRowMenu: ShortUrlsRowMenuType, colorGenerator: ColorGenerator, useTimeoutToggle: TimeoutToggle, ) => ({ shortUrl, onTagClick }: ShortUrlsRowProps) => { const [copiedToClipboard, setCopiedToClipboard] = useTimeoutToggle(); const [active, setActive] = useTimeoutToggle(false, 500); const isFirstRun = useRef(true); const [{ excludeBots }] = useShortUrlsQuery(); const visits = useSetting('visits'); const doExcludeBots = excludeBots ?? visits?.excludeBots; useEffect(() => { !isFirstRun.current && setActive(); isFirstRun.current = false; }, [shortUrl.visitsSummary?.total, shortUrl.visitsSummary?.nonBots, shortUrl.visitsCount]); return (