Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Clipclops] Separate messages if there's a time gap (#3777)

* separate msg groups by age

* clean up logic and add comments

authored by

Samuel Newman and committed by
GitHub
80bcf81d db968b76

+20 -2
+20 -2
src/screens/Messages/Conversation/MessageItem.tsx
··· 1 - import React, {useCallback} from 'react' 1 + import React, {useCallback, useMemo} from 'react' 2 2 import {StyleProp, TextStyle, View} from 'react-native' 3 3 import {msg} from '@lingui/macro' 4 4 import {useLingui} from '@lingui/react' ··· 25 25 TempDmChatDefs.isMessageView(next) && 26 26 next.sender?.did === getAgent().session?.did 27 27 28 - const isLastInGroup = !next || isFromSelf ? !isNextFromSelf : isNextFromSelf 28 + const isLastInGroup = useMemo(() => { 29 + // if the next message is from a different sender, then it's the last in the group 30 + if (isFromSelf ? !isNextFromSelf : isNextFromSelf) { 31 + return true 32 + } 33 + 34 + // or, if there's a 10 minute gap between this message and the next 35 + if (TempDmChatDefs.isMessageView(next)) { 36 + const thisDate = new Date(item.sentAt) 37 + const nextDate = new Date(next.sentAt) 38 + 39 + const diff = nextDate.getTime() - thisDate.getTime() 40 + 41 + // 10 minutes 42 + return diff > 10 * 60 * 1000 43 + } 44 + 45 + return true 46 + }, [item, next, isFromSelf, isNextFromSelf]) 29 47 30 48 return ( 31 49 <View>