-
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 Groups Refactored a few things
- Loading branch information
Alex Risch
authored and
Alex Risch
committed
Feb 8, 2024
1 parent
b6380e9
commit bdf4e69
Showing
24 changed files
with
1,924 additions
and
1,044 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 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,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() { |
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
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}} | ||
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'}}> | ||
{getMessageTimeDisplay(lastMessageTime)} | ||
</Text> | ||
</HStack> | ||
</Pressable> | ||
); | ||
}; |
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
Oops, something went wrong.