Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐴] Minor nits #4102

Merged
merged 4 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/screens/Messages/Conversation/MessagesList.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useCallback, useRef} from 'react'
import {FlatList, View} from 'react-native'
import Animated, {
dispatchCommand,
runOnJS,
scrollTo,
useAnimatedKeyboard,
useAnimatedReaction,
useAnimatedRef,
Expand Down Expand Up @@ -229,9 +229,14 @@ export function MessagesList({
return
}

// Only call this on every frame while _opening_ the keyboard
// We are setting some arbitrarily high number here to ensure that we end up scrolling to the bottom. There is not
// any other way to synchronously scroll to the bottom of the list, since we cannot get the content size of the
// scrollview synchronously.
// On iOS we could have used `dispatchCommand('scrollToEnd', [])` since the underlying view has a `scrollToEnd`
// method. It doesn't exist on Android though. That's probably why `scrollTo` which is implemented in Reanimated
// doesn't support a `scrollToEnd`.
if (prev && now > 0 && now >= prev) {
dispatchCommand(flatListRef, 'scrollToEnd', [false])
scrollTo(flatListRef, 0, 1e7, false)
}

// We want to store the full keyboard height after it fully opens so we can make some
Expand Down
11 changes: 9 additions & 2 deletions src/screens/Messages/List/ChatListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ import {Bell2Off_Filled_Corner0_Rounded as BellStroke} from '#/components/icons/
import {useMenuControl} from '#/components/Menu'
import {Text} from '#/components/Typography'

export function ChatListItem({convo}: {convo: ChatBskyConvoDefs.ConvoView}) {
export let ChatListItem = ({
convo,
}: {
convo: ChatBskyConvoDefs.ConvoView
}): React.ReactNode => {
const {currentAccount} = useSession()
const moderationOpts = useModerationOpts()

const otherUser = convo.members.find(
member => member.did !== currentAccount?.did,
)
const moderationOpts = useModerationOpts()

if (!otherUser || !moderationOpts) {
return null
Expand All @@ -45,6 +50,8 @@ export function ChatListItem({convo}: {convo: ChatBskyConvoDefs.ConvoView}) {
)
}

ChatListItem = React.memo(ChatListItem)

function ChatListItemReady({
convo,
profile: profileUnshadowed,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Messages/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function MessagesScreen({navigation, route}: Props) {
)
}, [_, t])

const initialNumToRender = useInitialNumToRender()
const initialNumToRender = useInitialNumToRender(80)
const [isPTRing, setIsPTRing] = useState(false)

const {
Expand Down
Loading