about summary refs log tree commit diff
path: root/src/components/Post/Embed/ListEmbed.tsx
blob: c1450bdcf9020c6ff7517d7fc302b7acc1f6650a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {useMemo} from 'react'
import {moderateUserList} from '@atproto/api'

import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {atoms as a, useTheme} from '#/alf'
import * as ListCard from '#/components/ListCard'
import {ContentHider} from '#/components/moderation/ContentHider'
import {type EmbedType} from '#/types/bsky/post'
import {type CommonProps} from './types'

export function ListEmbed({
  embed,
}: CommonProps & {
  embed: EmbedType<'list'>
}) {
  const t = useTheme()
  return (
    <ListCard.Default
      view={embed.view}
      style={[a.border, t.atoms.border_contrast_medium, a.p_md, a.rounded_sm]}
    />
  )
}

export function ModeratedListEmbed({
  embed,
}: CommonProps & {
  embed: EmbedType<'list'>
}) {
  const moderationOpts = useModerationOpts()
  const moderation = useMemo(() => {
    return moderationOpts
      ? moderateUserList(embed.view, moderationOpts)
      : undefined
  }, [embed.view, moderationOpts])
  return (
    <ContentHider
      modui={moderation?.ui('contentList')}
      childContainerStyle={[a.pt_xs]}>
      <ListEmbed embed={embed} />
    </ContentHider>
  )
}