Squash carousel in chat messages, fix rounding
This commit is contained in:
@@ -39,12 +39,11 @@ import {PostPlaceholder as PostPlaceholderText} from './PostPlaceholder'
|
|||||||
import {
|
import {
|
||||||
type CommonProps,
|
type CommonProps,
|
||||||
type EmbedProps,
|
type EmbedProps,
|
||||||
PostEmbedViewContext,
|
type PostEmbedViewContext,
|
||||||
QuoteEmbedViewContext,
|
|
||||||
} from './types'
|
} from './types'
|
||||||
import {VideoEmbed} from './VideoEmbed'
|
import {VideoEmbed} from './VideoEmbed'
|
||||||
|
|
||||||
export {PostEmbedViewContext, QuoteEmbedViewContext} from './types'
|
export {PostEmbedViewContext} from './types'
|
||||||
|
|
||||||
export function Embed({embed: rawEmbed, ...rest}: EmbedProps) {
|
export function Embed({embed: rawEmbed, ...rest}: EmbedProps) {
|
||||||
const embed = parseEmbed(rawEmbed)
|
const embed = parseEmbed(rawEmbed)
|
||||||
@@ -164,11 +163,7 @@ function RecordEmbed({
|
|||||||
<QuoteEmbed
|
<QuoteEmbed
|
||||||
{...rest}
|
{...rest}
|
||||||
embed={embed}
|
embed={embed}
|
||||||
viewContext={
|
viewContext={rest.viewContext}
|
||||||
rest.viewContext === PostEmbedViewContext.Feed
|
|
||||||
? QuoteEmbedViewContext.FeedEmbedRecordWithMedia
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
isWithinQuote={rest.isWithinQuote}
|
isWithinQuote={rest.isWithinQuote}
|
||||||
allowNestedQuotes={rest.allowNestedQuotes}
|
allowNestedQuotes={rest.allowNestedQuotes}
|
||||||
/>
|
/>
|
||||||
@@ -229,9 +224,10 @@ export function QuoteEmbed({
|
|||||||
linkDisabled,
|
linkDisabled,
|
||||||
isWithinQuote: parentIsWithinQuote,
|
isWithinQuote: parentIsWithinQuote,
|
||||||
allowNestedQuotes: parentAllowNestedQuotes,
|
allowNestedQuotes: parentAllowNestedQuotes,
|
||||||
|
viewContext,
|
||||||
}: Omit<CommonProps, 'viewContext'> & {
|
}: Omit<CommonProps, 'viewContext'> & {
|
||||||
embed: EmbedType<'post'>
|
embed: EmbedType<'post'>
|
||||||
viewContext?: QuoteEmbedViewContext
|
viewContext?: PostEmbedViewContext
|
||||||
linkDisabled?: boolean
|
linkDisabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
@@ -309,7 +305,7 @@ export function QuoteEmbed({
|
|||||||
<Embed
|
<Embed
|
||||||
embed={quote.embed}
|
embed={quote.embed}
|
||||||
moderation={moderation}
|
moderation={moderation}
|
||||||
viewContext={PostEmbedViewContext.FeedEmbedRecordWithMedia}
|
viewContext={viewContext}
|
||||||
isWithinQuote={parentIsWithinQuote ?? true}
|
isWithinQuote={parentIsWithinQuote ?? true}
|
||||||
// already within quote? override nested
|
// already within quote? override nested
|
||||||
allowNestedQuotes={
|
allowNestedQuotes={
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ export enum PostEmbedViewContext {
|
|||||||
ThreadHighlighted = 'ThreadHighlighted',
|
ThreadHighlighted = 'ThreadHighlighted',
|
||||||
Feed = 'Feed',
|
Feed = 'Feed',
|
||||||
FeedEmbedRecordWithMedia = 'FeedEmbedRecordWithMedia',
|
FeedEmbedRecordWithMedia = 'FeedEmbedRecordWithMedia',
|
||||||
}
|
ChatMessage = 'ChatMessage',
|
||||||
|
|
||||||
export enum QuoteEmbedViewContext {
|
|
||||||
FeedEmbedRecordWithMedia = PostEmbedViewContext.FeedEmbedRecordWithMedia,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CommonProps = {
|
export type CommonProps = {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ let MessageItemEmbed = ({
|
|||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
t.atoms.bg,
|
t.atoms.bg,
|
||||||
a.rounded_md,
|
|
||||||
native({
|
native({
|
||||||
flexBasis: 0,
|
flexBasis: 0,
|
||||||
width: Math.min(screen.width, 600) / 1.4,
|
width: Math.min(screen.width, 600) / 1.4,
|
||||||
@@ -47,9 +46,10 @@ let MessageItemEmbed = ({
|
|||||||
<Embed
|
<Embed
|
||||||
embed={embed}
|
embed={embed}
|
||||||
allowNestedQuotes
|
allowNestedQuotes
|
||||||
viewContext={PostEmbedViewContext.Feed}
|
viewContext={PostEmbedViewContext.ChatMessage}
|
||||||
style={[
|
style={[
|
||||||
a.rounded_xl,
|
a.rounded_xl,
|
||||||
|
a.overflow_hidden,
|
||||||
a.border_0,
|
a.border_0,
|
||||||
isFromSelf
|
isFromSelf
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -103,7 +103,14 @@ export function Gallery({
|
|||||||
const largeAltBadge = useLargeAltBadgeEnabled()
|
const largeAltBadge = useLargeAltBadgeEnabled()
|
||||||
const bps = useBreakpoints()
|
const bps = useBreakpoints()
|
||||||
const window = useWindowDimensions()
|
const window = useWindowDimensions()
|
||||||
|
const isWithinQuote =
|
||||||
|
viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia
|
||||||
|
const isWithinChat = viewContext === PostEmbedViewContext.ChatMessage
|
||||||
|
const hideBadges = isWithinQuote
|
||||||
const contentHeight = useMemo(() => {
|
const contentHeight = useMemo(() => {
|
||||||
|
if (isWithinChat) {
|
||||||
|
return 120
|
||||||
|
}
|
||||||
if (bps.gtMobile) {
|
if (bps.gtMobile) {
|
||||||
return 300
|
return 300
|
||||||
} else if (bps.gtPhone) {
|
} else if (bps.gtPhone) {
|
||||||
@@ -111,10 +118,7 @@ export function Gallery({
|
|||||||
} else {
|
} else {
|
||||||
return 200
|
return 200
|
||||||
}
|
}
|
||||||
}, [bps])
|
}, [bps, isWithinChat])
|
||||||
const isWithinQuote =
|
|
||||||
viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia
|
|
||||||
const hideBadges = isWithinQuote
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Container overflow styles
|
* Container overflow styles
|
||||||
|
|||||||
Reference in New Issue
Block a user