usePing
This commit is contained in:
parent
07bfdadd25
commit
b5f0b58898
|
@ -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 (
|
||||
<nav aria-label="Sidebar" className={className}>
|
||||
<ManifoldLogo className="py-6" twoLine />
|
||||
|
|
16
web/hooks/use-ping.ts
Normal file
16
web/hooks/use-ping.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { useEffect } from 'react'
|
||||
import { updateUser } from 'web/lib/firebase/users'
|
||||
|
||||
export const usePing = (userId: string | undefined) => {
|
||||
useEffect(() => {
|
||||
if (!userId) return
|
||||
|
||||
const pingInterval = setInterval(() => {
|
||||
updateUser(userId, {
|
||||
lastPingTime: Date.now(),
|
||||
})
|
||||
}, 1000 * 30)
|
||||
|
||||
return () => clearInterval(pingInterval)
|
||||
}, [userId])
|
||||
}
|
Loading…
Reference in New Issue
Block a user