···11-import React, {useCallback} from 'react'
11+import React, {useCallback, useMemo} from 'react'
22import {StyleProp, TextStyle, View} from 'react-native'
33import {msg} from '@lingui/macro'
44import {useLingui} from '@lingui/react'
···2525 TempDmChatDefs.isMessageView(next) &&
2626 next.sender?.did === getAgent().session?.did
27272828- const isLastInGroup = !next || isFromSelf ? !isNextFromSelf : isNextFromSelf
2828+ const isLastInGroup = useMemo(() => {
2929+ // if the next message is from a different sender, then it's the last in the group
3030+ if (isFromSelf ? !isNextFromSelf : isNextFromSelf) {
3131+ return true
3232+ }
3333+3434+ // or, if there's a 10 minute gap between this message and the next
3535+ if (TempDmChatDefs.isMessageView(next)) {
3636+ const thisDate = new Date(item.sentAt)
3737+ const nextDate = new Date(next.sentAt)
3838+3939+ const diff = nextDate.getTime() - thisDate.getTime()
4040+4141+ // 10 minutes
4242+ return diff > 10 * 60 * 1000
4343+ }
4444+4545+ return true
4646+ }, [item, next, isFromSelf, isNextFromSelf])
29473048 return (
3149 <View>