Use moderatePost_wrapped for post embeds (#4981)

* Use moderatePost_wrapped

* Add lint rule
zio/stable
Eric Bailey 2024-08-23 15:55:18 -05:00 committed by GitHub
parent b5ea87c981
commit fc5cc189b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 3 deletions

View File

@ -71,6 +71,19 @@ module.exports = {
'simple-import-sort/exports': 'warn',
// TODO: Reenable when we figure out why it gets stuck on CI.
// 'react-compiler/react-compiler': 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@atproto/api',
importNames: ['moderatePost'],
message:
'Please use `moderatePost_wrapped` from `#/lib/moderatePost_wrapped` instead.',
},
],
},
],
},
ignorePatterns: [
'**/__mocks__/*.ts',

View File

@ -1,4 +1,5 @@
import {moderatePost, BSKY_LABELER_DID} from '@atproto/api'
/* eslint-disable-next-line no-restricted-imports */
import {BSKY_LABELER_DID, moderatePost} from '@atproto/api'
type ModeratePost = typeof moderatePost
type Options = Parameters<ModeratePost>[1]

View File

@ -13,7 +13,6 @@ import {
AppBskyEmbedRecordWithMedia,
AppBskyFeedDefs,
AppBskyFeedPost,
moderatePost,
ModerationDecision,
RichText as RichTextAPI,
} from '@atproto/api'
@ -24,6 +23,7 @@ import {useLingui} from '@lingui/react'
import {useQueryClient} from '@tanstack/react-query'
import {HITSLOP_20} from '#/lib/constants'
import {moderatePost_wrapped} from '#/lib/moderatePost_wrapped'
import {s} from '#/lib/styles'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useSession} from '#/state/session'
@ -122,7 +122,7 @@ function QuoteEmbedModerated({
const moderationOpts = useModerationOpts()
const moderation = React.useMemo(() => {
return moderationOpts
? moderatePost(viewRecordToPostView(viewRecord), moderationOpts)
? moderatePost_wrapped(viewRecordToPostView(viewRecord), moderationOpts)
: undefined
}, [viewRecord, moderationOpts])

View File

@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */
import React from 'react'
import {View} from 'react-native'
import {