aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-06-11 15:30:56 -0400
committerIvan Chen <ivan@tagg.id>2021-06-11 15:30:56 -0400
commiteb672872d85f203085c96005758314d5dba359f2 (patch)
tree51507fdd6645045679928b83d9ed681695c7d2f0 /src/components
parent6ad0a54704523d7cb69b6789323ba26c4d53f63e (diff)
Simplify scroll logic, Cleanup code
Diffstat (limited to 'src/components')
-rw-r--r--src/components/moments/MomentPostContent.tsx7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx
index eb89fd03..da04211f 100644
--- a/src/components/moments/MomentPostContent.tsx
+++ b/src/components/moments/MomentPostContent.tsx
@@ -49,7 +49,8 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
);
const [commentPreview, setCommentPreview] =
useState<MomentCommentPreviewType | null>(moment.comment_preview);
- const {keyboardVisible, setScrollToTargetIndex} = useContext(MomentContext);
+ const {keyboardVisible, currentScrollToIndex, scrollTo} =
+ useContext(MomentContext);
useEffect(() => {
setTags(momentTags);
@@ -96,7 +97,7 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
/>
</Animated.View>
)}
- {!keyboardVisible && (
+ {(!keyboardVisible || currentScrollToIndex !== index) && (
<>
{moment.caption !== '' &&
renderTextWithMentions({
@@ -129,7 +130,7 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
comment: message,
})
}
- onFocus={() => setScrollToTargetIndex(index)}
+ onFocus={() => scrollTo(index)}
theme={'dark'}
/>
<Text style={styles.text}>{getTimePosted(moment.date_created)}</Text>