import Navbar from 'react-bootstrap/Navbar' import Nav from 'react-bootstrap/Nav' import Link from 'next/link' import styles from './header.module.css' import { useRouter } from 'next/router' import { Button, Container, NavDropdown } from 'react-bootstrap' import Price from './price' import { useMe } from './me' import Head from 'next/head' import { signOut, signIn } from 'next-auth/client' import { useLightning } from './lightning' import { useEffect, useState } from 'react' import { randInRange } from '../lib/rand' import { formatSats } from '../lib/format' import NoteIcon from '../svgs/notification-4-fill.svg' import { useQuery, gql } from '@apollo/client' function WalletSummary ({ me }) { if (!me) return null return `${formatSats(me.sats)}` } export default function Header ({ sub }) { const router = useRouter() const path = router.asPath.split('?')[0] const [fired, setFired] = useState() const me = useMe() const prefix = sub ? `/~${sub}` : '' const { data: subLatestPost } = useQuery(gql` query subLatestPost($name: ID!) { subLatestPost(name: $name) } `, { variables: { name: 'jobs' }, pollInterval: 600000, fetchPolicy: 'network-only' }) const [lastCheckedJobs, setLastCheckedJobs] = useState(new Date().getTime()) useEffect(() => { if (me) { setLastCheckedJobs(me.lastCheckedJobs) } else { if (sub === 'jobs') { localStorage.setItem('lastCheckedJobs', new Date().getTime()) } setLastCheckedJobs(localStorage.getItem('lastCheckedJobs')) } }) const Corner = () => { if (me) { return (