import { FC, useEffect, useRef } from 'react'; import { isEmpty } from 'ramda'; import { ExternalLink } from 'react-external-link'; import ColorGenerator from '../../utils/services/ColorGenerator'; import { StateFlagTimeout } from '../../utils/helpers/hooks'; import Tag from '../../tags/helpers/Tag'; import { SelectedServer } from '../../servers/data'; import { CopyToClipboardIcon } from '../../utils/CopyToClipboardIcon'; import { ShortUrl } from '../data'; import { Time } from '../../utils/Time'; import ShortUrlVisitsCount from './ShortUrlVisitsCount'; import { ShortUrlsRowMenuProps } from './ShortUrlsRowMenu'; import './ShortUrlsRow.scss'; export interface ShortUrlsRowProps { onTagClick?: (tag: string) => void; selectedServer: SelectedServer; shortUrl: ShortUrl; } const ShortUrlsRow = ( ShortUrlsRowMenu: FC, colorGenerator: ColorGenerator, useStateFlagTimeout: StateFlagTimeout, ) => ({ shortUrl, selectedServer, onTagClick }: ShortUrlsRowProps) => { const [copiedToClipboard, setCopiedToClipboard] = useStateFlagTimeout(); const [active, setActive] = useStateFlagTimeout(false, 500); const isFirstRun = useRef(true); const renderTags = (tags: string[]) => { if (isEmpty(tags)) { return No tags; } return tags.map((tag) => ( onTagClick?.(tag)} /> )); }; useEffect(() => { if (isFirstRun.current) { isFirstRun.current = false; } else { setActive(); } }, [shortUrl.visitsCount]); return (