Skip to content

Commit

Permalink
Added Groups
Browse files Browse the repository at this point in the history
Added Groups
Refactored a few things
  • Loading branch information
Alex Risch authored and Alex Risch committed Feb 8, 2024
1 parent b6380e9 commit bdf4e69
Show file tree
Hide file tree
Showing 24 changed files with 1,924 additions and 1,044 deletions.
50 changes: 25 additions & 25 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ PODS:
- Connect-Swift (0.3.0):
- SwiftProtobuf (~> 1.20.3)
- DoubleConversion (1.1.6)
- EXApplication (5.4.0):
- EXApplication (5.8.3):
- ExpoModulesCore
- EXConstants (15.4.5):
- ExpoModulesCore
- EXFont (11.10.2):
- ExpoModulesCore
- Expo (50.0.1):
- Expo (50.0.6):
- ExpoModulesCore
- ExpoClipboard (4.5.0):
- ExpoClipboard (4.8.0):
- ExpoModulesCore
- ExpoDocumentPicker (11.7.0):
- ExpoDocumentPicker (11.10.1):
- ExpoModulesCore
- ExpoFileSystem (16.0.4):
- ExpoFileSystem (16.0.6):
- ExpoModulesCore
- ExpoKeepAwake (12.8.2):
- ExpoModulesCore
- ExpoModulesCore (1.11.7):
- ExpoModulesCore (1.11.8):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- React-NativeModulesApple
- React-RCTAppDelegate
- ReactCommon/turbomodule/core
- ExpoSecureStore (12.5.0):
- ExpoSecureStore (12.8.1):
- ExpoModulesCore
- FBLazyVector (0.73.2)
- FBReactNativeSpec (0.73.2):
Expand Down Expand Up @@ -110,6 +110,7 @@ PODS:
- hermes-engine/Pre-built (= 0.73.0)
- hermes-engine/Pre-built (0.73.0)
- libevent (2.1.12)
- LibXMTP (0.4.1-beta0)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (1.3.2):
Expand Down Expand Up @@ -1193,7 +1194,7 @@ PODS:
- React-Core
- RNLocalize (3.0.6):
- React-Core
- RNReanimated (3.6.1):
- RNReanimated (3.6.2):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
Expand All @@ -1216,17 +1217,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.7.7-alpha0):
- XMTP (0.7.8-alpha0):
- Connect-Swift (= 0.3.0)
- GzipSwift
- LibXMTP (= 0.4.1-beta0)
- web3.swift
- XMTPRust (= 0.3.7-beta0)
- XMTPReactNative (1.25.1):
- XMTPReactNative (1.27.0-beta.2):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.7.7-alpha0)
- XMTPRust (0.3.7-beta0)
- XMTP (= 0.7.8-alpha0)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1355,6 +1355,7 @@ SPEC REPOS:
- GenericJSON
- GzipSwift
- libevent
- LibXMTP
- Logging
- MessagePacker
- MMKV
Expand All @@ -1365,7 +1366,6 @@ SPEC REPOS:
- SwiftProtobuf
- web3.swift
- XMTP
- XMTPRust

EXTERNAL SOURCES:
boost:
Expand Down Expand Up @@ -1539,16 +1539,16 @@ SPEC CHECKSUMS:
CoinbaseWalletSDKExpo: c79420eb009f482f768c23b6768fc5b2d7c98777
Connect-Swift: d38eedc1907d440314f8d26d5a038a00cbb0f6f1
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
EXApplication: 2a0d9abd4feace9c6faedfe541c1dec02e3702cd
EXApplication: 137189a3f149b4e8e546884629392c3efc94cbd3
EXConstants: 988aa430ca0f76b43cd46b66e7fae3287f9cc2fc
EXFont: 21b9c760abd593ce8f0d5386b558ced76018506f
Expo: 08cf73d1f27103bdcdfba181c81469ac4b15ac5a
ExpoClipboard: d2f0e44d50e5ba07b02f5fb7bd280178b420e24e
ExpoDocumentPicker: d3b6b0ed2dbbc2f05158e0294dd3f4673f386e5f
ExpoFileSystem: 39e454b8e7f2358ae2c8f8ec255fede4c3039493
Expo: fb745b3074989670b6641f9f20463e8ee56a69ca
ExpoClipboard: b8f76767b0dbaefb3be7adbf85049fd85861d527
ExpoDocumentPicker: 70254802886e29a45d4ad25486e64b6fc9c8f0cc
ExpoFileSystem: a9273932e69a9a1e1a8d01b6ba895bb8294bbea2
ExpoKeepAwake: 0f5cad99603a3268e50af9a6eb8b76d0d9ac956c
ExpoModulesCore: f103ff1346136b2926e1654f32b3f45ab0b74830
ExpoSecureStore: 5372610a4bbcf5e50fafbe6f38f8d9c22edf8253
ExpoModulesCore: 96d1751929ad10622773bb729ab28a8423f0dd0c
ExpoSecureStore: c84ae37d1c36f38524d289c67c3a2e3fc56f1108
FBLazyVector: fbc4957d9aa695250b55d879c1d86f79d7e69ab4
FBReactNativeSpec: 86de768f89901ef6ed3207cd686362189d64ac88
Flipper: c7a0093234c4bdd456e363f2f19b2e4b27652d44
Expand All @@ -1565,6 +1565,7 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: 34304f8c6e8fa68f63a5fe29af82f227d817d7a7
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: a3bb8d00c275034e55f1f7bf632335821c792d3c
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: f21593c0af4b3f2a0ceb8f820f28bb639ea22bb7
Expand Down Expand Up @@ -1625,7 +1626,7 @@ SPEC CHECKSUMS:
RNCClipboard: 60fed4b71560d7bfe40e9d35dea9762b024da86d
RNDeviceInfo: db5c64a060e66e5db3102d041ebe3ef307a85120
RNLocalize: 4222a3756cdbe2dc9a5bdf445765a4d2572107cb
RNReanimated: 57f436e7aa3d277fbfed05e003230b43428157c0
RNReanimated: 5589be82dc26b3f94738eb7c6b1f942787532b25
RNScreens: b582cb834dc4133307562e930e8fa914b8c04ef2
RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
Expand All @@ -1634,9 +1635,8 @@ SPEC CHECKSUMS:
SwiftProtobuf: b02b5075dcf60c9f5f403000b3b0c202a11b6ae1
WatermelonDB: 842d22ba555425aa9f3ce551239a001200c539bc
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: b2488aa96eced55fd41a5aece1334be6b5ab622d
XMTPReactNative: 5c1ce9decb8722bbbe8cf41dd2179d60f56078f9
XMTPRust: 8848a2ba761b2c961d666632f2ad27d1082faa93
XMTP: 7c308fde3213aa0b0ad8198c9984932260f22b65
XMTPReactNative: a1f72b1ebcf181b57052cd2cbf55615c0687887d
Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047

PODFILE CHECKSUM: c765268d8eab018a5f4619e1d00ca4dab437bc4f
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"lint": "eslint .",
"start": "react-native start",
"test": "jest",
"tsc": "tsc",
"postinstall": "patch-package && npx pod-install",
"e2e:ios:build": "detox build --configuration ios.sim.debug",
"e2e:ios:test": "detox test --configuration ios.sim.debug",
Expand All @@ -26,7 +27,7 @@
"@tanstack/react-query": "^5.17.19",
"@thirdweb-dev/react-native": "^0.5.4",
"@thirdweb-dev/react-native-compat": "^0.5.4",
"@xmtp/react-native-sdk": "1.25.1",
"@xmtp/react-native-sdk": "1.27.0-beta.2",
"aws-sdk": "^2.1540.0",
"ethers": "^5",
"expo": ">=50.0.0-0 <51.0.0",
Expand Down
88 changes: 88 additions & 0 deletions patches/@xmtp+react-native-sdk+1.27.0-beta.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
diff --git a/node_modules/@xmtp/react-native-sdk/src/index.ts b/node_modules/@xmtp/react-native-sdk/src/index.ts
index 31dfa58..a222d8d 100644
--- a/node_modules/@xmtp/react-native-sdk/src/index.ts
+++ b/node_modules/@xmtp/react-native-sdk/src/index.ts
@@ -6,10 +6,10 @@ import { ConversationContext } from './XMTP.types'
import XMTPModule from './XMTPModule'
import { ConsentListEntry, ConsentState } from './lib/ConsentListEntry'
import {
+ ContentCodec,
DecryptedLocalAttachment,
EncryptedLocalAttachment,
PreparedLocalMessage,
- ContentCodec,
} from './lib/ContentCodec'
import { Conversation } from './lib/Conversation'
import { DecodedMessage } from './lib/DecodedMessage'
@@ -17,14 +17,14 @@ import { Group } from './lib/Group'
import type { Query } from './lib/Query'
import { getAddress } from './utils/address'

+export * from './context'
+export * from './hooks'
export { ReactionCodec } from './lib/NativeCodecs/ReactionCodec'
-export { ReplyCodec } from './lib/NativeCodecs/ReplyCodec'
export { ReadReceiptCodec } from './lib/NativeCodecs/ReadReceiptCodec'
-export { StaticAttachmentCodec } from './lib/NativeCodecs/StaticAttachmentCodec'
export { RemoteAttachmentCodec } from './lib/NativeCodecs/RemoteAttachmentCodec'
+export { ReplyCodec } from './lib/NativeCodecs/ReplyCodec'
+export { StaticAttachmentCodec } from './lib/NativeCodecs/StaticAttachmentCodec'
export { TextCodec } from './lib/NativeCodecs/TextCodec'
-export * from './hooks'
-export * from './context'

const EncodedContent = content.EncodedContent

@@ -119,10 +119,13 @@ export async function sendMessageToGroup(
}

export async function groupMessages(
- clientAddress: string,
+ client: Client<any>,
id: string
): Promise<DecodedMessage[]> {
- return await XMTPModule.groupMessages(clientAddress, id)
+ const messages = await XMTPModule.groupMessages(client.address, id)
+ return messages.map((json: string) => {
+ return DecodedMessage.from(json, client)
+ })
}

export async function syncGroups(clientAddress: string) {
@@ -484,11 +487,11 @@ export function preCreateIdentityCallbackCompleted() {

export const emitter = new EventEmitter(XMTPModule ?? NativeModulesProxy.XMTP)

-export * from './lib/ContentCodec'
+export * from './XMTP.types'
export { Client } from './lib/Client'
+export * from './lib/ContentCodec'
export { Conversation } from './lib/Conversation'
-export * from './XMTP.types'
export { Query } from './lib/Query'
export { XMTPPush } from './lib/XMTPPush'
-export { DecodedMessage }
-export { ConsentListEntry }
+export { ConsentListEntry, DecodedMessage }
+
diff --git a/node_modules/@xmtp/react-native-sdk/src/lib/Group.ts b/node_modules/@xmtp/react-native-sdk/src/lib/Group.ts
index 4cfd460..e32baa4 100644
--- a/node_modules/@xmtp/react-native-sdk/src/lib/Group.ts
+++ b/node_modules/@xmtp/react-native-sdk/src/lib/Group.ts
@@ -1,6 +1,6 @@
+import * as XMTP from '../index'
import { SendOptions } from './Conversation'
import { DecodedMessage } from './DecodedMessage'
-import * as XMTP from '../index'

export class Group<ContentTypes> {
client: XMTP.Client<ContentTypes>
@@ -62,7 +62,7 @@ export class Group<ContentTypes> {
}

async messages(): Promise<DecodedMessage[]> {
- return await XMTP.groupMessages(this.client.address, this.id)
+ return await XMTP.groupMessages(this.client, this.id)
}

async sync() {
25 changes: 8 additions & 17 deletions src/components/ConversationInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,31 @@ import {colors} from '../theme/colors';
interface ConversationInputProps {
sendMessage: (payload: {text?: string; asset?: Asset}) => void;
currentAddress?: string;
topic?: string;
id?: string;
}

export const ConversationInput: FC<ConversationInputProps> = ({
sendMessage,
currentAddress,
topic,
id,
}) => {
const [focused, setFocus] = useState<boolean>(false);
const [text, setText] = useState<string>(
currentAddress && topic ? getDraftText(currentAddress, topic) ?? '' : '',
currentAddress && id ? getDraftText(currentAddress, id) ?? '' : '',
);
const [asset, setAssetUri] = useState<Asset | null>();
// currentAddress && topic
// ? getDraftImage(currentAddress, topic) ?? null
// : null,

useEffect(() => {
if (text && currentAddress && topic) {
saveDraftText(currentAddress, topic, text);
if (text && currentAddress && id) {
saveDraftText(currentAddress, id, text);
}
if (!text && currentAddress && topic) {
clearDraftText(currentAddress, topic);
if (!text && currentAddress && id) {
clearDraftText(currentAddress, id);
}
}, [currentAddress, text, topic]);

// useEffect(() => {
// if (asset && currentAddress && topic) {
// // saveDraftImage(currentAddress, topic, assetUri);
// }
// if (!asset && currentAddress && topic) {
// // clearDraftImage(currentAddress, topic);
// }
// }, [currentAddress, assetUri, topic]);
}, [currentAddress, text, id]);

const handleImageUploadPress = useCallback(() => {
launchImageLibrary(
Expand Down
60 changes: 60 additions & 0 deletions src/components/ConversationListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {Conversation} from '@xmtp/react-native-sdk';
import {HStack, VStack} from 'native-base';
import React, {FC} from 'react';
import {Pressable} from 'react-native';
import {useContactInfo} from '../hooks/useContactInfo';
import {useTypedNavigation} from '../hooks/useTypedNavigation';
import {ScreenNames} from '../navigation/ScreenNames';
import {getMessageTimeDisplay} from '../utils/getMessageTimeDisplay';
import {AvatarWithFallback} from './AvatarWithFallback';
import {Text} from './common/Text';

interface ConversationListItemProps {
conversation: Conversation<any>;
display: string;
lastMessageTime: number;
}

export const ConversationListItem: FC<ConversationListItemProps> = ({
conversation,
display,
lastMessageTime,
}) => {
const {navigate} = useTypedNavigation();
const {displayName, avatarUrl} = useContactInfo(conversation.peerAddress);

return (
<Pressable
onPress={() => {
navigate(ScreenNames.Conversation, {
topic: conversation.topic,
});
}}>
<HStack space={[2, 3]} alignItems={'center'} w={'100%'} padding={'16px'}>
<AvatarWithFallback
avatarUri={avatarUrl}
size={48}
style={{marginRight: 16}}

Check warning on line 37 in src/components/ConversationListItem.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { marginRight: 16 }
address={conversation.peerAddress}
/>
<VStack flex={1} justifyContent={'flex-end'}>
<Text
numberOfLines={1}
ellipsizeMode="middle"
typography="text-base/bold">
{displayName}
</Text>
<Text numberOfLines={1} typography="text-sm/regular">
{display}
</Text>
</VStack>
<Text
alignSelf={'flex-start'}
typography="text-xs/regular"
style={{textAlignVertical: 'top'}}>

Check warning on line 54 in src/components/ConversationListItem.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { textAlignVertical: 'top' }
{getMessageTimeDisplay(lastMessageTime)}
</Text>
</HStack>
</Pressable>
);
};
5 changes: 2 additions & 3 deletions src/components/ConversationMessageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import {Text} from './common/Text';

interface ConversationMessageContentProps {
message: DecodedMessage<unknown>;
address: string;
isMe: boolean;
}

export const ConversationMessageContent: FC<
ConversationMessageContentProps
> = ({message, address}) => {
> = ({message, isMe}) => {
if (message.contentTypeId === 'xmtp.org/text:1.0') {
const isMe = message.senderAddress === address;
return (
<Container
backgroundColor={
Expand Down
Loading

0 comments on commit bdf4e69

Please sign in to comment.