import { useEffect } from "react"; import { Link, Routes } from "blitz"; import { HiPhoneMissedCall, HiPhoneIncoming, HiPhoneOutgoing } from "react-icons/hi"; import clsx from "clsx"; import { Direction, CallStatus } from "db"; import PhoneInitLoader from "app/core/components/phone-init-loader"; import EmptyCalls from "../components/empty-calls"; import usePhoneCalls from "../hooks/use-phone-calls"; import { formatRelativeDate } from "app/core/helpers/date-formatter"; import useCurrentUser from "app/core/hooks/use-current-user"; export default function PhoneCallsList() { const { hasOngoingSubscription } = useCurrentUser(); const [phoneCalls, query] = usePhoneCalls(); useEffect(() => { if (!phoneCalls) { const pollInterval = setInterval(() => query.refetch(), 1500); return () => clearInterval(pollInterval); } }, [phoneCalls, query]); if (!phoneCalls) { return hasOngoingSubscription ? : null; } if (phoneCalls.length === 0) { return hasOngoingSubscription ? : null; } return ( ); }