From b5f0b5889827fbb5f864418110d83532558199dd Mon Sep 17 00:00:00 2001 From: mantikoros Date: Sun, 17 Jul 2022 15:17:31 -0500 Subject: [PATCH] usePing --- web/components/nav/sidebar.tsx | 15 ++++----------- web/hooks/use-ping.ts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 web/hooks/use-ping.ts diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index 55f11b16..5c3b9128 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -13,7 +13,7 @@ import clsx from 'clsx' import Link from 'next/link' import { useRouter } from 'next/router' import { usePrivateUser, useUser } from 'web/hooks/use-user' -import { firebaseLogout, updateUser, User } from 'web/lib/firebase/users' +import { firebaseLogout, User } from 'web/lib/firebase/users' import { ManifoldLogo } from './manifold-logo' import { MenuButton } from './menu' import { ProfileSummary } from './profile-menu' @@ -193,10 +193,13 @@ export default function Sidebar(props: { className?: string }) { const user = useUser() const privateUser = usePrivateUser(user?.id) + // usePing(user?.id) + const navigationOptions = !user ? signedOutNavigation : getNavigation() const mobileNavigationOptions = !user ? signedOutMobileNavigation : signedInMobileNavigation + const memberItems = ( useMemberGroups( user?.id, @@ -208,16 +211,6 @@ export default function Sidebar(props: { className?: string }) { href: `${groupPath(group.slug)}/${GROUP_CHAT_SLUG}`, })) - useEffect(() => { - if (!user) return - const pingInterval = setInterval(() => { - updateUser(user.id, { - lastPingTime: Date.now(), - }) - }, 1000 * 30) - return () => clearInterval(pingInterval) - }, [user]) - return (