diff options
author | dan <dan.abramov@gmail.com> | 2023-11-17 17:31:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 09:31:26 -0800 |
commit | c858b583072d7858f50ee0d56bb76dbce5a9c13d (patch) | |
tree | 6fa7e969abc71b1b21c7586856bf013b8a3a96c8 /src/view | |
parent | 9c8a1b8a3118f6a6994a3c6cf8e5b70ef10049ab (diff) | |
download | voidsky-c858b583072d7858f50ee0d56bb76dbce5a9c13d.tar.zst |
Do less work (#1953)
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/com/post-thread/PostThreadItem.tsx | 9 | ||||
-rw-r--r-- | src/view/com/post/Post.tsx | 2 | ||||
-rw-r--r-- | src/view/com/posts/FeedItem.tsx | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 0e2fb7080..f66c01d85 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -1,4 +1,4 @@ -import React, {useMemo} from 'react' +import React, {memo, useMemo} from 'react' import {StyleSheet, View} from 'react-native' import { AtUri, @@ -118,7 +118,7 @@ function PostThreadItemDeleted() { ) } -function PostThreadItemLoaded({ +let PostThreadItemLoaded = ({ post, record, richText, @@ -144,12 +144,12 @@ function PostThreadItemLoaded({ showParentReplyLine?: boolean hasPrecedingItem: boolean onPostReply: () => void -}) { +}): React.ReactNode => { const pal = usePalette('default') const langPrefs = useLanguagePrefs() const {openComposer} = useComposerControls() const [limitLines, setLimitLines] = React.useState( - countLines(richText?.text) >= MAX_POST_LINES, + () => countLines(richText?.text) >= MAX_POST_LINES, ) const styles = useStyles() const hasEngagement = post.likeCount || post.repostCount @@ -565,6 +565,7 @@ function PostThreadItemLoaded({ ) } } +PostThreadItemLoaded = memo(PostThreadItemLoaded) function PostOuterWrapper({ post, diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index a2a0e62e6..00dd4419f 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -99,7 +99,7 @@ function PostInner({ const pal = usePalette('default') const {openComposer} = useComposerControls() const [limitLines, setLimitLines] = useState( - countLines(richText?.text) >= MAX_POST_LINES, + () => countLines(richText?.text) >= MAX_POST_LINES, ) const itemUrip = new AtUri(post.uri) const itemHref = makeProfileLink(post.author, 'post', itemUrip.rkey) diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 786b879af..19f2b0e6c 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -106,7 +106,7 @@ let FeedItemInner = ({ const pal = usePalette('default') const {track} = useAnalytics() const [limitLines, setLimitLines] = useState( - countLines(richText.text) >= MAX_POST_LINES, + () => countLines(richText.text) >= MAX_POST_LINES, ) const href = useMemo(() => { |