diff --git a/src/screens/Notifications/components/NotificationItem/Item/aggregate.tsx b/src/screens/Notifications/components/NotificationItem/Item/aggregate.tsx index 4ae768716..b12ef123a 100644 --- a/src/screens/Notifications/components/NotificationItem/Item/aggregate.tsx +++ b/src/screens/Notifications/components/NotificationItem/Item/aggregate.tsx @@ -11,7 +11,7 @@ import {Text} from '#/components/Typography' import {app} from '#/lexicons' import * as bsky from '#/types/bsky' import {getPostThumbnails} from './media' -import {QuoteCard} from './post' +import {Quote} from './post' import {SecondaryText} from './text' /** @@ -58,7 +58,7 @@ export function PostPreview({ if (!embed) return null if (embed.type === 'quote') { - return + return } const domain = embed.domain diff --git a/src/screens/Notifications/components/NotificationItem/Item/post.tsx b/src/screens/Notifications/components/NotificationItem/Item/post.tsx index 0b0e0b2e7..7d7644c81 100644 --- a/src/screens/Notifications/components/NotificationItem/Item/post.tsx +++ b/src/screens/Notifications/components/NotificationItem/Item/post.tsx @@ -19,26 +19,23 @@ import { import {useModerationOpts} from '#/state/preferences/moderation-opts' import {type ParentPost} from '#/state/queries/notifications/grouped/types' import {useSession} from '#/state/session' -import {TimeElapsed} from '#/view/com/util/TimeElapsed' -import {UserAvatar} from '#/view/com/util/UserAvatar' -import {atoms as a, useTheme, web} from '#/alf' +import {atoms as a, tokens, useTheme, web} from '#/alf' import {ArrowCornerDownRight_Stroke2_Corner2_Rounded as ArrowCornerDownRight} from '#/components/icons/Arrow' import {type Props as SVGIconProps} from '#/components/icons/common' -import {Link, WebOnlyInlineLinkText} from '#/components/Link' +import {WebOnlyInlineLinkText} from '#/components/Link' import {ContentHider} from '#/components/moderation/ContentHider' import {PostAlerts} from '#/components/moderation/PostAlerts' +import {Embed} from '#/components/Post/Embed' import {ExternalEmbed} from '#/components/Post/Embed/ExternalEmbed' import {ShowMoreTextButton} from '#/components/Post/ShowMoreTextButton' import {PostControls} from '#/components/PostControls' import {ProfileBadges} from '#/components/ProfileBadges' import {ProfileHoverCard} from '#/components/ProfileHoverCard' import {RichText} from '#/components/RichText' -import {SubtleHover} from '#/components/SubtleHover' import {Text} from '#/components/Typography' import {app} from '#/lexicons' import * as bsky from '#/types/bsky' -import {makePostLink} from '../links' -import {Card, FeedCard, getPostThumbnails, InlineImages} from './media' +import {FeedCard, getPostThumbnails, InlineImages} from './media' import {Strong, useDisplayName} from './text' type PostView = app.bsky.feed.defs.PostView @@ -389,7 +386,7 @@ function hasRecordCard(embed: app.bsky.embed.record.View) { } /** - * The card for a record embed: a quoted post, or a feed that was shared. + * A record embed: a quoted post, or a card for a feed that was shared. * Without it a post that shares a feed reads like a plain reply to whoever * made the feed. Other records, like lists, render nothing. */ @@ -399,13 +396,13 @@ function RecordPreview({embed}: {embed: app.bsky.embed.record.View}) { if (parsed.type === 'feed') { return } - return + return } /** * A compact stand-in for the full post embed: thumbnails for media, the - * usual external embed for links, a card for quoted posts and shared feeds, - * and nothing for lists and the like. + * usual external embed for links, the usual quote for quoted posts, a card + * for shared feeds, and nothing for lists and the like. */ function EmbedPreview({ embed, @@ -447,191 +444,32 @@ function EmbedPreview({ } /** - * Compact preview of a quoted post: author, time and the start of its text. - * Pressing it opens the quoted post. Blocked, deleted and detached quotes - * collapse to a short muted line, and other record embeds render nothing. + * A quoted post, rendered by the same `Embed` that feeds use. Blocked, + * deleted and detached quotes get its usual placeholders, and other record + * embeds render nothing. */ -export function QuoteCard({ - embed, - numberOfLines = 2, - isMuted = false, -}: { - embed: app.bsky.embed.record.View - /** - * How many lines of the quoted post's text to show. - */ - numberOfLines?: number - /** - * Mutes the quoted post's text, as for a preview of the post. - */ - isMuted?: boolean -}) { - const t = useTheme() - const {currentAccount} = useSession() - const parsed = bsky.post.parseEmbedRecordView(embed) - - let placeholder: React.ReactNode = null - switch (parsed.type) { +export function Quote({embed}: {embed: app.bsky.embed.record.View}) { + switch (bsky.post.parseEmbedRecordView(embed).type) { case 'post': - return ( - - ) case 'post_blocked': - placeholder = Blocked post - break case 'post_not_found': - placeholder = Deleted post - break - case 'post_detached': { - const isViewerOwner = currentAccount?.did - ? parsed.view.uri.includes(currentAccount.did) - : false - placeholder = isViewerOwner ? ( - Removed by you - ) : ( - Removed by author - ) + case 'post_detached': break - } default: return null } return ( - - - {placeholder} - - - ) -} - -function QuoteCardPost({ - view, - numberOfLines, - isMuted, -}: { - view: app.bsky.embed.record.ViewRecord - numberOfLines: number - isMuted: boolean -}) { - const t = useTheme() - const {t: l} = useLingui() - const moderationOpts = useModerationOpts() - const name = useDisplayName(view.author) - const quote: PostView = { - ...view, - $type: 'app.bsky.feed.defs#postView', - record: view.value, - embed: view.embeds?.[0], - } - const moderation = moderationOpts - ? moderatePost(quote, moderationOpts) - : undefined - const href = makePostLink(view) - const quotedRecord = bsky.isType(app.bsky.feed.post, view.value) - ? view.value - : undefined - - return ( - - - {({hovered, pressed}) => ( - - - - - - {forceLTR(name)} - - - {sanitizeHandle(view.author.handle, '@')} - - - · - - - {({timeElapsed}) => ( - - {timeElapsed} - - )} - - - {quotedRecord?.text.trim() ? ( - - ) : ( - - )} - - )} - - + /* + * `Embed` gives quotes a top margin, for the post text above them, which + * the row's own spacing already covers. + */ + + + ) }