allow nested quotes in DMs (#4345)
parent
d918f8dc2a
commit
2ffb98e22a
|
@ -14,7 +14,7 @@ let MessageItemEmbed = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[a.my_xs, t.atoms.bg, native({flexBasis: 0})]}>
|
<View style={[a.my_xs, t.atoms.bg, native({flexBasis: 0})]}>
|
||||||
<PostEmbeds embed={embed} />
|
<PostEmbeds embed={embed} allowNestedQuotes />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import React from 'react'
|
||||||
import {
|
import {
|
||||||
StyleProp,
|
StyleProp,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
TextStyle,
|
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
View,
|
View,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
|
@ -32,7 +31,7 @@ import {InfoCircleIcon} from 'lib/icons'
|
||||||
import {makeProfileLink} from 'lib/routes/links'
|
import {makeProfileLink} from 'lib/routes/links'
|
||||||
import {precacheProfile} from 'state/queries/profile'
|
import {precacheProfile} from 'state/queries/profile'
|
||||||
import {ComposerOptsQuote} from 'state/shell/composer'
|
import {ComposerOptsQuote} from 'state/shell/composer'
|
||||||
import {atoms as a, flatten} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
import {RichText} from '#/components/RichText'
|
import {RichText} from '#/components/RichText'
|
||||||
import {ContentHider} from '../../../../components/moderation/ContentHider'
|
import {ContentHider} from '../../../../components/moderation/ContentHider'
|
||||||
import {PostAlerts} from '../../../../components/moderation/PostAlerts'
|
import {PostAlerts} from '../../../../components/moderation/PostAlerts'
|
||||||
|
@ -46,12 +45,12 @@ export function MaybeQuoteEmbed({
|
||||||
embed,
|
embed,
|
||||||
onOpen,
|
onOpen,
|
||||||
style,
|
style,
|
||||||
textStyle,
|
allowNestedQuotes,
|
||||||
}: {
|
}: {
|
||||||
embed: AppBskyEmbedRecord.View
|
embed: AppBskyEmbedRecord.View
|
||||||
onOpen?: () => void
|
onOpen?: () => void
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
textStyle?: StyleProp<TextStyle>
|
allowNestedQuotes?: boolean
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
if (
|
if (
|
||||||
|
@ -65,7 +64,7 @@ export function MaybeQuoteEmbed({
|
||||||
postRecord={embed.record.value}
|
postRecord={embed.record.value}
|
||||||
onOpen={onOpen}
|
onOpen={onOpen}
|
||||||
style={style}
|
style={style}
|
||||||
textStyle={textStyle}
|
allowNestedQuotes={allowNestedQuotes}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
} else if (AppBskyEmbedRecord.isViewBlocked(embed.record)) {
|
} else if (AppBskyEmbedRecord.isViewBlocked(embed.record)) {
|
||||||
|
@ -95,13 +94,13 @@ function QuoteEmbedModerated({
|
||||||
postRecord,
|
postRecord,
|
||||||
onOpen,
|
onOpen,
|
||||||
style,
|
style,
|
||||||
textStyle,
|
allowNestedQuotes,
|
||||||
}: {
|
}: {
|
||||||
viewRecord: AppBskyEmbedRecord.ViewRecord
|
viewRecord: AppBskyEmbedRecord.ViewRecord
|
||||||
postRecord: AppBskyFeedPost.Record
|
postRecord: AppBskyFeedPost.Record
|
||||||
onOpen?: () => void
|
onOpen?: () => void
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
textStyle?: StyleProp<TextStyle>
|
allowNestedQuotes?: boolean
|
||||||
}) {
|
}) {
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const moderation = React.useMemo(() => {
|
const moderation = React.useMemo(() => {
|
||||||
|
@ -126,7 +125,7 @@ function QuoteEmbedModerated({
|
||||||
moderation={moderation}
|
moderation={moderation}
|
||||||
onOpen={onOpen}
|
onOpen={onOpen}
|
||||||
style={style}
|
style={style}
|
||||||
textStyle={textStyle}
|
allowNestedQuotes={allowNestedQuotes}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -136,13 +135,13 @@ export function QuoteEmbed({
|
||||||
moderation,
|
moderation,
|
||||||
onOpen,
|
onOpen,
|
||||||
style,
|
style,
|
||||||
textStyle,
|
allowNestedQuotes,
|
||||||
}: {
|
}: {
|
||||||
quote: ComposerOptsQuote
|
quote: ComposerOptsQuote
|
||||||
moderation?: ModerationDecision
|
moderation?: ModerationDecision
|
||||||
onOpen?: () => void
|
onOpen?: () => void
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
textStyle?: StyleProp<TextStyle>
|
allowNestedQuotes?: boolean
|
||||||
}) {
|
}) {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
|
@ -161,6 +160,9 @@ export function QuoteEmbed({
|
||||||
const embed = React.useMemo(() => {
|
const embed = React.useMemo(() => {
|
||||||
const e = quote.embeds?.[0]
|
const e = quote.embeds?.[0]
|
||||||
|
|
||||||
|
if (allowNestedQuotes) {
|
||||||
|
return e
|
||||||
|
} else {
|
||||||
if (AppBskyEmbedImages.isView(e) || AppBskyEmbedExternal.isView(e)) {
|
if (AppBskyEmbedImages.isView(e) || AppBskyEmbedExternal.isView(e)) {
|
||||||
return e
|
return e
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -170,7 +172,8 @@ export function QuoteEmbed({
|
||||||
) {
|
) {
|
||||||
return e.media
|
return e.media
|
||||||
}
|
}
|
||||||
}, [quote.embeds])
|
}
|
||||||
|
}, [quote.embeds, allowNestedQuotes])
|
||||||
|
|
||||||
const onBeforePress = React.useCallback(() => {
|
const onBeforePress = React.useCallback(() => {
|
||||||
precacheProfile(queryClient, quote.author)
|
precacheProfile(queryClient, quote.author)
|
||||||
|
@ -201,7 +204,7 @@ export function QuoteEmbed({
|
||||||
{richText ? (
|
{richText ? (
|
||||||
<RichText
|
<RichText
|
||||||
value={richText}
|
value={richText}
|
||||||
style={[a.text_md, flatten(textStyle)]}
|
style={a.text_md}
|
||||||
numberOfLines={20}
|
numberOfLines={20}
|
||||||
disableLinks
|
disableLinks
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
StyleProp,
|
StyleProp,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
TextStyle,
|
|
||||||
View,
|
View,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
@ -42,13 +41,13 @@ export function PostEmbeds({
|
||||||
moderation,
|
moderation,
|
||||||
onOpen,
|
onOpen,
|
||||||
style,
|
style,
|
||||||
quoteTextStyle,
|
allowNestedQuotes,
|
||||||
}: {
|
}: {
|
||||||
embed?: Embed
|
embed?: Embed
|
||||||
moderation?: ModerationDecision
|
moderation?: ModerationDecision
|
||||||
onOpen?: () => void
|
onOpen?: () => void
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
quoteTextStyle?: StyleProp<TextStyle>
|
allowNestedQuotes?: boolean
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {openLightbox} = useLightboxControls()
|
const {openLightbox} = useLightboxControls()
|
||||||
|
@ -63,11 +62,7 @@ export function PostEmbeds({
|
||||||
moderation={moderation}
|
moderation={moderation}
|
||||||
onOpen={onOpen}
|
onOpen={onOpen}
|
||||||
/>
|
/>
|
||||||
<MaybeQuoteEmbed
|
<MaybeQuoteEmbed embed={embed.record} onOpen={onOpen} />
|
||||||
embed={embed.record}
|
|
||||||
onOpen={onOpen}
|
|
||||||
textStyle={quoteTextStyle}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -98,8 +93,8 @@ export function PostEmbeds({
|
||||||
<MaybeQuoteEmbed
|
<MaybeQuoteEmbed
|
||||||
embed={embed}
|
embed={embed}
|
||||||
style={style}
|
style={style}
|
||||||
textStyle={quoteTextStyle}
|
|
||||||
onOpen={onOpen}
|
onOpen={onOpen}
|
||||||
|
allowNestedQuotes={allowNestedQuotes}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue