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

feat: Identity #117

Merged
merged 2 commits into from
May 31, 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
12 changes: 10 additions & 2 deletions ios/EphemeraMobileChat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,11 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
OTHER_LDFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -741,7 +745,11 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
OTHER_LDFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
Expand Down
20 changes: 10 additions & 10 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ PODS:
- libwebp/sharpyuv (1.3.2)
- libwebp/webp (1.3.2):
- libwebp/sharpyuv
- LibXMTP (0.4.4-beta5)
- LibXMTP (0.5.0-beta2)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (1.3.5):
Expand Down Expand Up @@ -1240,16 +1240,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.10.11):
- XMTP (0.11.1):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.4.4-beta5)
- LibXMTP (= 0.5.0-beta2)
- web3.swift
- XMTPReactNative (1.33.1-beta.2):
- XMTPReactNative (1.34.0-beta.2):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.10.11)
- XMTP (= 0.11.1)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1588,7 +1588,7 @@ SPEC CHECKSUMS:
hermes-engine: b12d9bb1b7cee546f5e48212e7ea7e3c1665a367
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
LibXMTP: e2fb601691981900099551ff3e05621bd73dccf1
LibXMTP: 0a2e98cc3b101e53538c54061633e6587dc861bf
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: 506311d0494023c2f7e0b62cc1f31b7370fa3cfb
Expand Down Expand Up @@ -1664,10 +1664,10 @@ SPEC CHECKSUMS:
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
WatermelonDB: 842d22ba555425aa9f3ce551239a001200c539bc
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: 1deb40ac712ba315dcfdecd590a9b924d8c2241a
XMTPReactNative: ffc7fb00c38f3d3f8af038ae5d1f9712cac0bb5f
Yoga: e5b887426cee15d2a326bdd34afc0282fc0486ad
XMTP: b2145642aae614c82b8115d479442f58513139b6
XMTPReactNative: cb23f376c29cd889a4c360eb2d4bb4417bc37690
Yoga: 2a16e58450c48e110211dae1159fb114bbcdcfc0

PODFILE CHECKSUM: 47641fd2f7a6fc6169785131e7615d136e56edd8

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@tanstack/react-query": "^5.36.2",
"@tanstack/react-query-persist-client": "^5.36.2",
"@xmtp/frames-client": "^0.5.1",
"@xmtp/react-native-sdk": "1.33.1-beta.2",
"@xmtp/react-native-sdk": "1.34.0-beta.2",
"aws-sdk": "^2.1540.0",
"expo": ">=50.0.0-0 <51.0.0",
"fastestsmallesttextencoderdecoder": "1.0.22",
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/@xmtp/react-native-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
JSContentCodec: jest.fn().mockImplementation(() => {
return {};
}),
GroupChangeCodec: jest.fn().mockImplementation(() => {
GroupUpdatedCodec: jest.fn().mockImplementation(() => {
return {};
}),
ReplyCodec: jest.fn().mockImplementation(() => ({})),
Expand Down
12 changes: 6 additions & 6 deletions src/components/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ import {ConversationMessageContent} from './messageContent/ConversationMessageCo

export interface MessageProps {
message: DecodedMessage<SupportedContentTypes>;
isMe: boolean;
isFromUser: boolean;
reactions: MessageIdReactionsMapping[string];
}

export const Message: FC<MessageProps> = ({message, isMe, reactions}) => {
export const Message: FC<MessageProps> = ({message, isFromUser, reactions}) => {
if (message.contentTypeId === ContentTypes.Reaction) {
return null;
}
return (
<Pressable>
<Box marginLeft={6} marginRight={6} marginY={2} flexShrink={1}>
<VStack>
{!isMe && (
{!isFromUser && (
<VStack justifyItems={'flex-end'}>
<Text
color={colors.primaryN200}
Expand All @@ -39,17 +39,17 @@ export const Message: FC<MessageProps> = ({message, isMe, reactions}) => {
)}
<ConversationMessageContent
message={message}
isMe={isMe}
isFromUser={isFromUser}
reactions={reactions}
/>
<Text
flexShrink={1}
color={colors.primaryN200}
typography="text-xs/semi-bold"
alignSelf={
message.contentTypeId === ContentTypes.GroupMembershipChange
message.contentTypeId === ContentTypes.GroupUpdated
? 'center'
: isMe
: isFromUser
? 'flex-end'
: 'flex-start'
}>
Expand Down
46 changes: 23 additions & 23 deletions src/components/messageContent/ConversationMessageContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
DecodedMessage,
GroupChangeContent,
GroupUpdatedContent,
RemoteAttachmentContent,
} from '@xmtp/react-native-sdk';
import {Container} from 'native-base';
Expand All @@ -18,7 +18,7 @@ import {TextMessageContent} from './TextMessageContent';

interface ConversationMessageContentProps {
message: DecodedMessage<SupportedContentTypes>;
isMe: boolean;
isFromUser: boolean;
reactions: MessageIdReactionsMapping[string];
}

Expand All @@ -32,7 +32,7 @@ export type ReactionItems = ReactionItem[];

export const ConversationMessageContent: FC<
ConversationMessageContentProps
> = ({message, isMe, reactions}) => {
> = ({message, isFromUser, reactions}) => {
const reacts = useMemo(() => {
const arr: ReactionItems = [];
for (const content of reactions.keys()) {
Expand All @@ -51,9 +51,9 @@ export const ConversationMessageContent: FC<
return (
<MessageOptionsContainer
reactions={reacts}
isMe={isMe}
isFromUser={isFromUser}
messageId={message.id}>
<TextMessageContent isMe={isMe} message={message} />
<TextMessageContent isFromUser={isFromUser} message={message} />
</MessageOptionsContainer>
);
}
Expand All @@ -62,12 +62,12 @@ export const ConversationMessageContent: FC<
return (
<MessageOptionsContainer
reactions={reacts}
isMe={isMe}
isFromUser={isFromUser}
messageId={message.id}>
<Container
borderRadius={'16px'}
borderBottomRightRadius={isMe ? 0 : '16px'}
borderTopLeftRadius={isMe ? '16px' : 0}
borderBottomRightRadius={isFromUser ? 0 : '16px'}
borderTopLeftRadius={isFromUser ? '16px' : 0}
paddingY={3}>
<ImageMessage
content={message.content() as RemoteAttachmentContent}
Expand All @@ -77,39 +77,39 @@ export const ConversationMessageContent: FC<
);
}

if (message.contentTypeId === ContentTypes.GroupMembershipChange) {
const content = message.content() as GroupChangeContent;
if (message.contentTypeId === ContentTypes.GroupUpdated) {
const content = message.content() as GroupUpdatedContent;
let text = '';
if (content?.membersAdded.length > 0) {
if (content?.membersAdded.length > 1) {
text = translate('group_add_plural', {
initiatedByAddress: formatAddress(
content?.membersAdded[0].initiatedByAddress ?? '',
initiatedByInboxId: formatAddress(
content?.membersAdded[0].initiatedByInboxId ?? '',
),
addressCount: String(content?.membersAdded.length),
count: String(content?.membersAdded.length),
});
} else {
text = translate('group_add_single', {
initiatedByAddress: formatAddress(
content?.membersAdded[0].initiatedByAddress,
initiatedByInboxId: formatAddress(
content?.membersAdded[0].initiatedByInboxId,
),
address: formatAddress(content?.membersAdded[0].address),
inboxId: formatAddress(content?.membersAdded[0].inboxId),
});
}
} else if (content?.membersRemoved.length > 0) {
if (content?.membersRemoved.length > 1) {
text = translate('group_remove_plural', {
initiatedByAddress: formatAddress(
content?.membersRemoved[0].initiatedByAddress,
initiatedByInboxId: formatAddress(
content?.membersRemoved[0].initiatedByInboxId,
),
addressCount: String(content?.membersRemoved.length),
});
} else {
text = translate('group_remove_single', {
initiatedByAddress: formatAddress(
content?.membersRemoved[0].initiatedByAddress,
initiatedByInboxId: formatAddress(
content?.membersRemoved[0].initiatedByInboxId,
),
address: formatAddress(content?.membersRemoved[0].address),
inboxId: formatAddress(content?.membersRemoved[0].inboxId),
});
}
}
Expand All @@ -133,9 +133,9 @@ export const ConversationMessageContent: FC<
return (
<MessageOptionsContainer
reactions={reacts}
isMe={isMe}
isFromUser={isFromUser}
messageId={message.id}>
<ReplyMessageContent message={message} isMe={isMe} />
<ReplyMessageContent message={message} isFromUser={isFromUser} />
</MessageOptionsContainer>
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/messageContent/MessageOptionsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {ReactionItems} from './ConversationMessageContent';

export const MessageOptionsContainer: FC<
PropsWithChildren<{
isMe: boolean;
isFromUser: boolean;
messageId: string;
reactions: ReactionItems;
}>
> = ({children, isMe, messageId, reactions}) => {
> = ({children, isFromUser, messageId, reactions}) => {
const [shown, setShown] = useState(false);
const {group, setReplyId} = useContext(GroupContext);

Expand Down Expand Up @@ -75,8 +75,8 @@ export const MessageOptionsContainer: FC<
<Pressable onPress={handlePress} onLongPress={handleLongPress}>
<Container
flexShrink={1}
alignSelf={isMe ? 'flex-end' : 'flex-start'}
alignItems={isMe ? 'flex-end' : 'flex-start'}
alignSelf={isFromUser ? 'flex-end' : 'flex-start'}
alignItems={isFromUser ? 'flex-end' : 'flex-start'}
borderRadius={'16px'}>
{children}
{reactions.length > 0 && (
Expand Down
22 changes: 12 additions & 10 deletions src/components/messageContent/ReplyMessageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import {ImageMessage} from '../ImageMessage';

interface ReplyMessageContentProps {
message: DecodedMessage<SupportedContentTypes>;
isMe: boolean;
isFromUser: boolean;
}

export const ReplyMessageContent = ({
message,
isMe,
isFromUser,
}: ReplyMessageContentProps) => {
const {scrollToMessage} = useContext(GroupContext);

Expand All @@ -39,17 +39,19 @@ export const ReplyMessageContent = ({
return (
<Container
backgroundColor={
isMe ? colors.actionPrimary : colors.backgroundSecondary
isFromUser ? colors.actionPrimary : colors.backgroundSecondary
}
alignSelf={isMe ? 'flex-end' : 'flex-start'}
alignSelf={isFromUser ? 'flex-end' : 'flex-start'}
borderRadius={'16px'}
borderBottomRightRadius={isMe ? 0 : '16px'}
borderTopLeftRadius={isMe ? '16px' : 0}
borderBottomRightRadius={isFromUser ? 0 : '16px'}
borderTopLeftRadius={isFromUser ? '16px' : 0}
paddingY={3}
paddingX={5}>
<Text
typography="text-base/medium"
color={isMe ? colors.actionPrimaryText : colors.textPrimary}>
color={
isFromUser ? colors.actionPrimaryText : colors.textPrimary
}>
{textContent.text}
</Text>
</Container>
Expand All @@ -61,7 +63,7 @@ export const ReplyMessageContent = ({
default:
return null;
}
}, [isMe, reply]);
}, [isFromUser, reply]);

const handlePress = useCallback(() => {
if (reply.reference) {
Expand All @@ -75,8 +77,8 @@ export const ReplyMessageContent = ({
return (
<Container
borderRadius={'16px'}
borderBottomRightRadius={isMe ? 0 : '16px'}
borderTopLeftRadius={isMe ? '16px' : 0}>
borderBottomRightRadius={isFromUser ? 0 : '16px'}
borderTopLeftRadius={isFromUser ? '16px' : 0}>
<Pressable onPress={handlePress}>
<Text typography="text-xs/regular" color={colors.textSecondary}>
{translate('replied_to')}
Expand Down
18 changes: 9 additions & 9 deletions src/components/messageContent/TextMessageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import {Text} from '../common/Text';

export const TextMessageContent = ({
isMe,
isFromUser,
message,
}: {
isMe: boolean;
isFromUser: boolean;
message: DecodedMessage<SupportedContentTypes>;
}) => {
const {width} = useWindowDimensions();
Expand All @@ -22,16 +22,16 @@
return (
<Container
backgroundColor={
isMe ? colors.actionPrimary : colors.backgroundSecondary
isFromUser ? colors.actionPrimary : colors.backgroundSecondary
}
borderRadius={'16px'}
borderBottomRightRadius={isMe ? 0 : '16px'}
borderTopLeftRadius={isMe ? '16px' : 0}
borderBottomRightRadius={isFromUser ? 0 : '16px'}
borderTopLeftRadius={isFromUser ? '16px' : 0}
paddingY={3}
paddingX={5}>
<Text
typography="text-base/medium"
color={isMe ? colors.actionPrimaryText : colors.textPrimary}>
color={isFromUser ? colors.actionPrimaryText : colors.textPrimary}>
{message.content() as string}
</Text>
</Container>
Expand All @@ -43,16 +43,16 @@

return (
<Box
alignSelf={isMe ? 'flex-end' : 'flex-start'}
alignSelf={isFromUser ? 'flex-end' : 'flex-start'}
borderRadius={'16px'}
borderBottomRightRadius={isMe ? 0 : '16px'}
borderTopLeftRadius={isMe ? '16px' : 0}
borderBottomRightRadius={isFromUser ? 0 : '16px'}
borderTopLeftRadius={isFromUser ? '16px' : 0}
paddingY={3}
paddingX={5}>
<FastImage
resizeMode="contain"
source={{uri: frameData.image?.content}}
style={{

Check warning on line 55 in src/components/messageContent/TextMessageContent.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { borderRadius: 10 }
height: imageHeight,
width: imageWidth,
borderRadius: 10,
Expand Down
Loading
Loading