[Clipclops] Improve message list behaviour (#3789)

* improve message list behaviour

* replace useAgent with useSession

* add explicit types to appease linter
This commit is contained in:
Samuel Newman 2024-05-01 15:16:54 +01:00 committed by GitHub
parent b8d8bec388
commit 09f3b2ae14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 45 additions and 18 deletions

View file

@ -3,7 +3,7 @@ import {StyleProp, TextStyle, View} from 'react-native'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useAgent} from '#/state/session'
import {useSession} from '#/state/session'
import {TimeElapsed} from '#/view/com/util/TimeElapsed'
import {atoms as a, useTheme} from '#/alf'
import {Text} from '#/components/Typography'
@ -17,13 +17,13 @@ export function MessageItem({
next: TempDmChatDefs.MessageView | TempDmChatDefs.DeletedMessage | null
}) {
const t = useTheme()
const {getAgent} = useAgent()
const {currentAccount} = useSession()
const isFromSelf = item.sender?.did === getAgent().session?.did
const isFromSelf = item.sender?.did === currentAccount?.did
const isNextFromSelf =
TempDmChatDefs.isMessageView(next) &&
next.sender?.did === getAgent().session?.did
next.sender?.did === currentAccount?.did
const isLastInGroup = useMemo(() => {
// if the next message is from a different sender, then it's the last in the group