QT Jump Pt. 2 - Remove code duplication (#3506)
* remove code duplication * now it's safe to remove shimmerzio/stable
parent
7047755c50
commit
eb2fd53340
|
@ -11,7 +11,7 @@ import {getAgent} from '#/state/session'
|
||||||
import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from './notifications/feed'
|
import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from './notifications/feed'
|
||||||
import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from './post-feed'
|
import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from './post-feed'
|
||||||
import {precacheThreadPostProfiles} from './profile'
|
import {precacheThreadPostProfiles} from './profile'
|
||||||
import {getEmbeddedPost} from './util'
|
import {embedViewRecordToPostView, getEmbeddedPost} from './util'
|
||||||
|
|
||||||
const RQKEY_ROOT = 'post-thread'
|
const RQKEY_ROOT = 'post-thread'
|
||||||
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
|
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
|
||||||
|
@ -332,14 +332,7 @@ function embedViewRecordToPlaceholderThread(
|
||||||
type: 'post',
|
type: 'post',
|
||||||
_reactKey: record.uri,
|
_reactKey: record.uri,
|
||||||
uri: record.uri,
|
uri: record.uri,
|
||||||
post: {
|
post: embedViewRecordToPostView(record),
|
||||||
uri: record.uri,
|
|
||||||
cid: record.cid,
|
|
||||||
author: record.author,
|
|
||||||
record: record.value,
|
|
||||||
indexedAt: record.indexedAt,
|
|
||||||
labels: record.labels,
|
|
||||||
},
|
|
||||||
record: record.value as AppBskyFeedPost.Record, // validated in getEmbeddedPost
|
record: record.value as AppBskyFeedPost.Record, // validated in getEmbeddedPost
|
||||||
parent: undefined,
|
parent: undefined,
|
||||||
replies: undefined,
|
replies: undefined,
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
import React, {memo, useMemo} from 'react'
|
import React, {memo, useMemo} from 'react'
|
||||||
import {StyleSheet, View} from 'react-native'
|
import {StyleSheet, View} from 'react-native'
|
||||||
import {
|
import {
|
||||||
AtUri,
|
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
AppBskyFeedPost,
|
AppBskyFeedPost,
|
||||||
RichText as RichTextAPI,
|
AtUri,
|
||||||
ModerationDecision,
|
ModerationDecision,
|
||||||
|
RichText as RichTextAPI,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped'
|
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {PostThreadFollowBtn} from 'view/com/post-thread/PostThreadFollowBtn'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {Link, TextLink} from '../util/Link'
|
import {useLingui} from '@lingui/react'
|
||||||
import {RichText} from '#/components/RichText'
|
|
||||||
import {Text} from '../util/text/Text'
|
import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped'
|
||||||
import {PreviewableUserAvatar} from '../util/UserAvatar'
|
import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow'
|
||||||
import {s} from 'lib/styles'
|
import {useLanguagePrefs} from '#/state/preferences'
|
||||||
import {niceDate} from 'lib/strings/time'
|
import {useOpenLink} from '#/state/preferences/in-app-browser'
|
||||||
|
import {ThreadPost} from '#/state/queries/post-thread'
|
||||||
|
import {useModerationOpts} from '#/state/queries/preferences'
|
||||||
|
import {useComposerControls} from '#/state/shell/composer'
|
||||||
|
import {MAX_POST_LINES} from 'lib/constants'
|
||||||
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
|
import {makeProfileLink} from 'lib/routes/links'
|
||||||
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
||||||
import {sanitizeHandle} from 'lib/strings/handles'
|
import {sanitizeHandle} from 'lib/strings/handles'
|
||||||
import {countLines, pluralize} from 'lib/strings/helpers'
|
import {countLines, pluralize} from 'lib/strings/helpers'
|
||||||
import {getTranslatorLink, isPostInLanguage} from '../../../locale/helpers'
|
import {niceDate} from 'lib/strings/time'
|
||||||
import {PostMeta} from '../util/PostMeta'
|
import {s} from 'lib/styles'
|
||||||
import {PostEmbeds} from '../util/post-embeds'
|
|
||||||
import {PostCtrls} from '../util/post-ctrls/PostCtrls'
|
|
||||||
import {PostHider} from '../../../components/moderation/PostHider'
|
|
||||||
import {ContentHider} from '../../../components/moderation/ContentHider'
|
|
||||||
import {PostAlerts} from '../../../components/moderation/PostAlerts'
|
|
||||||
import {LabelsOnMyPost} from '../../../components/moderation/LabelsOnMe'
|
|
||||||
import {ErrorMessage} from '../util/error/ErrorMessage'
|
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
|
||||||
import {formatCount} from '../util/numeric/format'
|
|
||||||
import {makeProfileLink} from 'lib/routes/links'
|
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
|
||||||
import {MAX_POST_LINES} from 'lib/constants'
|
|
||||||
import {Trans, msg} from '@lingui/macro'
|
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
import {useLanguagePrefs} from '#/state/preferences'
|
|
||||||
import {useComposerControls} from '#/state/shell/composer'
|
|
||||||
import {useModerationOpts} from '#/state/queries/preferences'
|
|
||||||
import {useOpenLink} from '#/state/preferences/in-app-browser'
|
|
||||||
import {Shadow, usePostShadow, POST_TOMBSTONE} from '#/state/cache/post-shadow'
|
|
||||||
import {ThreadPost} from '#/state/queries/post-thread'
|
|
||||||
import {useSession} from 'state/session'
|
import {useSession} from 'state/session'
|
||||||
import {WhoCanReply} from '../threadgate/WhoCanReply'
|
import {PostThreadFollowBtn} from 'view/com/post-thread/PostThreadFollowBtn'
|
||||||
import {LoadingPlaceholder} from '../util/LoadingPlaceholder'
|
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
|
import {RichText} from '#/components/RichText'
|
||||||
|
import {ContentHider} from '../../../components/moderation/ContentHider'
|
||||||
|
import {LabelsOnMyPost} from '../../../components/moderation/LabelsOnMe'
|
||||||
|
import {PostAlerts} from '../../../components/moderation/PostAlerts'
|
||||||
|
import {PostHider} from '../../../components/moderation/PostHider'
|
||||||
|
import {getTranslatorLink, isPostInLanguage} from '../../../locale/helpers'
|
||||||
|
import {WhoCanReply} from '../threadgate/WhoCanReply'
|
||||||
|
import {ErrorMessage} from '../util/error/ErrorMessage'
|
||||||
|
import {Link, TextLink} from '../util/Link'
|
||||||
|
import {formatCount} from '../util/numeric/format'
|
||||||
|
import {PostCtrls} from '../util/post-ctrls/PostCtrls'
|
||||||
|
import {PostEmbeds} from '../util/post-embeds'
|
||||||
|
import {PostMeta} from '../util/PostMeta'
|
||||||
|
import {Text} from '../util/text/Text'
|
||||||
|
import {PreviewableUserAvatar} from '../util/UserAvatar'
|
||||||
|
|
||||||
export function PostThreadItem({
|
export function PostThreadItem({
|
||||||
post,
|
post,
|
||||||
|
@ -325,12 +325,6 @@ let PostThreadItemLoaded = ({
|
||||||
{post.repostCount !== 0 || post.likeCount !== 0 ? (
|
{post.repostCount !== 0 || post.likeCount !== 0 ? (
|
||||||
// Show this section unless we're *sure* it has no engagement.
|
// Show this section unless we're *sure* it has no engagement.
|
||||||
<View style={[styles.expandedInfo, pal.border]}>
|
<View style={[styles.expandedInfo, pal.border]}>
|
||||||
{post.repostCount == null && post.likeCount == null && (
|
|
||||||
// If we're still loading and not sure, assume this post has engagement.
|
|
||||||
// This lets us avoid a layout shift for the common case (embedded post with likes/reposts).
|
|
||||||
// TODO: embeds should include metrics to avoid us having to guess.
|
|
||||||
<LoadingPlaceholder width={50} height={20} />
|
|
||||||
)}
|
|
||||||
{post.repostCount != null && post.repostCount !== 0 ? (
|
{post.repostCount != null && post.repostCount !== 0 ? (
|
||||||
<Link
|
<Link
|
||||||
style={styles.expandedInfoItem}
|
style={styles.expandedInfoItem}
|
||||||
|
|
Loading…
Reference in New Issue