index.tsx raw

   1  import NoteList from '@/components/NoteList'
   2  import { ExtendedKind } from '@/constants'
   3  import client from '@/services/client.service'
   4  import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
   5  import { normalizeUrl, simplifyUrl } from '@/lib/url'
   6  import { forwardRef, useMemo } from 'react'
   7  import { useTranslation } from 'react-i18next'
   8  import NotFoundPage from '../NotFoundPage'
   9  
  10  const RelayReviewsPage = forwardRef(({ url, index }: { url?: string; index?: number }, ref) => {
  11    const { t } = useTranslation()
  12    const normalizedUrl = useMemo(() => (url ? normalizeUrl(url) : undefined), [url])
  13    const title = useMemo(
  14      () => (url ? t('Reviews for {{relay}}', { relay: simplifyUrl(url) }) : undefined),
  15      [url]
  16    )
  17  
  18    if (!normalizedUrl) {
  19      return <NotFoundPage ref={ref} />
  20    }
  21  
  22    return (
  23      <SecondaryPageLayout ref={ref} index={index} title={title} displayScrollToTopButton>
  24        <NoteList
  25          showKinds={[ExtendedKind.RELAY_REVIEW]}
  26          subRequests={[
  27            {
  28              urls: [normalizedUrl, ...client.currentRelays],
  29              filter: { '#d': [normalizedUrl] }
  30            }
  31          ]}
  32          hideSpam
  33        />
  34      </SecondaryPageLayout>
  35    )
  36  })
  37  RelayReviewsPage.displayName = 'RelayReviewsPage'
  38  export default RelayReviewsPage
  39