-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Reaction support for messages Added persistance handling Refactored providers Removed conversation screen
- Loading branch information
Alex Risch
authored and
Alex Risch
committed
May 17, 2024
1 parent
ade4757
commit df4d6f1
Showing
26 changed files
with
805 additions
and
819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {DecodedMessage} from '@xmtp/react-native-sdk'; | ||
import {Box, VStack} from 'native-base'; | ||
import React, {FC} from 'react'; | ||
import {Pressable} from 'react-native'; | ||
import {ContentTypes, SupportedContentTypes} from '../consts/ContentTypes'; | ||
import {MessageIdReactionsMapping} from '../queries/useGroupMessagesQuery'; | ||
import {mmkvStorage} from '../services/mmkvStorage'; | ||
import {colors} from '../theme/colors'; | ||
import {formatAddress} from '../utils/formatAddress'; | ||
import {getMessageTimeDisplay} from '../utils/getMessageTimeDisplay'; | ||
import {Text} from './common/Text'; | ||
import {ConversationMessageContent} from './messageContent/ConversationMessageContent'; | ||
|
||
export interface MessageProps { | ||
message: DecodedMessage<SupportedContentTypes>; | ||
isMe: boolean; | ||
reactions: MessageIdReactionsMapping[string]; | ||
} | ||
|
||
export const Message: FC<MessageProps> = ({message, isMe, reactions}) => { | ||
if (message.contentTypeId === ContentTypes.Reaction) { | ||
return null; | ||
} | ||
return ( | ||
<Pressable> | ||
<Box marginLeft={6} marginRight={6} marginY={2} flexShrink={1}> | ||
<VStack> | ||
{!isMe && ( | ||
<VStack justifyItems={'flex-end'}> | ||
<Text | ||
color={colors.primaryN200} | ||
textAlign={'end'} | ||
typography="text-xs/semi-bold" | ||
alignSelf={'flex-start'}> | ||
{mmkvStorage.getEnsName(message.senderAddress) ?? | ||
formatAddress(message.senderAddress)} | ||
</Text> | ||
</VStack> | ||
)} | ||
<ConversationMessageContent | ||
message={message} | ||
isMe={isMe} | ||
reactions={reactions} | ||
/> | ||
<Text | ||
flexShrink={1} | ||
color={colors.primaryN200} | ||
typography="text-xs/semi-bold" | ||
alignSelf={ | ||
message.contentTypeId === ContentTypes.GroupMembershipChange | ||
? 'center' | ||
: isMe | ||
? 'flex-end' | ||
: 'flex-start' | ||
}> | ||
{getMessageTimeDisplay(message.sent)} | ||
</Text> | ||
</VStack> | ||
</Box> | ||
</Pressable> | ||
); | ||
}; |
Oops, something went wrong.