diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ContentJson.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ContentJson.kt index 8bc15b85f..45e6280f1 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ContentJson.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ContentJson.kt @@ -176,7 +176,7 @@ class ContentJson( ) ContentTypeGroupUpdated.id -> mapOf( - "groupChange" to mapOf( + "groupUpdated" to mapOf( "membersAdded" to (content as GroupUpdated).addedInboxesList.map { mapOf( "inboxId" to it.inboxId, diff --git a/example/src/GroupScreen.tsx b/example/src/GroupScreen.tsx index c55116d26..38c2a5357 100644 --- a/example/src/GroupScreen.tsx +++ b/example/src/GroupScreen.tsx @@ -31,7 +31,7 @@ import { StaticAttachmentContent, ReplyContent, useClient, - GroupChangeContent, + GroupUpdatedContent, } from 'xmtp-react-native-sdk' import { ConversationSendPayload } from 'xmtp-react-native-sdk/lib/types' @@ -1074,16 +1074,16 @@ function formatAddress(address: string) { return `${address.slice(0, 6)}…${address.slice(-4)}` } -function GroupChangeContents({ content }: { content: GroupChangeContent }) { +function GroupUpdatedContents({ content }: { content: GroupUpdatedContent }) { return ( <> {content.membersAdded.length > 0 && (content.membersAdded.length === 1 ? ( {`${formatAddress( - content.membersAdded[0].address + content.membersAdded[0].inboxId )} has been added by ${formatAddress( - content.membersAdded[0].initiatedByAddress + content.membersAdded[0].initiatedByInboxId )}`} ) : ( @@ -1091,7 +1091,7 @@ function GroupChangeContents({ content }: { content: GroupChangeContent }) { {`${ content.membersAdded.length } members have been added by ${formatAddress( - content.membersAdded[0].initiatedByAddress + content.membersAdded[0].initiatedByInboxId )}`} ))} @@ -1099,9 +1099,9 @@ function GroupChangeContents({ content }: { content: GroupChangeContent }) { (content.membersRemoved.length === 1 ? ( {`${formatAddress( - content.membersRemoved[0].address + content.membersRemoved[0].inboxId )} has been removed by ${formatAddress( - content.membersRemoved[0].initiatedByAddress + content.membersRemoved[0].initiatedByInboxId )}`} ) : ( @@ -1109,7 +1109,7 @@ function GroupChangeContents({ content }: { content: GroupChangeContent }) { {`${ content.membersRemoved.length } members have been removed by ${formatAddress( - content.membersRemoved[0].initiatedByAddress + content.membersRemoved[0].initiatedByInboxId )}`} ))} @@ -1172,7 +1172,7 @@ function MessageContents({ ) } if (contentTypeId === 'xmtp.org/group_membership_change:1.0') { - return + return } return ( diff --git a/example/src/contentTypes/contentTypes.ts b/example/src/contentTypes/contentTypes.ts index 966ce8f90..51b3e1e74 100644 --- a/example/src/contentTypes/contentTypes.ts +++ b/example/src/contentTypes/contentTypes.ts @@ -1,5 +1,5 @@ import { - GroupChangeCodec, + GroupUpdatedCodec, ReactionCodec, ReplyCodec, RemoteAttachmentCodec, @@ -11,7 +11,7 @@ export const supportedCodecs = [ new ReplyCodec(), new RemoteAttachmentCodec(), new StaticAttachmentCodec(), - new GroupChangeCodec(), + new GroupUpdatedCodec(), ] export type SupportedContentTypes = typeof supportedCodecs diff --git a/ios/Wrappers/DecodedMessageWrapper.swift b/ios/Wrappers/DecodedMessageWrapper.swift index b52f3617e..03fd5c305 100644 --- a/ios/Wrappers/DecodedMessageWrapper.swift +++ b/ios/Wrappers/DecodedMessageWrapper.swift @@ -163,15 +163,15 @@ struct ContentJson { case ContentTypeReadReceipt.id where content is XMTP.ReadReceipt: return ["readReceipt": ""] case ContentTypeGroupUpdated.id where content is XMTP.GroupUpdated: - let groupChange = content as! XMTP.GroupUpdated - return ["groupChange": [ - "membersAdded": groupChange.addedInboxes.map { member in + let groupUpdated = content as! XMTP.GroupUpdated + return ["groupUpdated": [ + "membersAdded": groupUpdated.addedInboxes.map { member in [ "inboxId": member.inboxID, "initiatedByInboxId": member.initiatedByInboxID ] }, - "membersRemoved": groupChange.removedInboxes.map { member in + "membersRemoved": groupUpdated.removedInboxes.map { member in [ "inboxId": member.inboxID, "initiatedByInboxId": member.initiatedByInboxID diff --git a/src/index.ts b/src/index.ts index 559c9ef88..ed720fb6e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,7 @@ import { getAddress } from './utils/address' export * from './context' export * from './hooks' -export { GroupChangeCodec } from './lib/NativeCodecs/GroupChangeCodec' +export { GroupUpdatedCodec } from './lib/NativeCodecs/GroupUpdatedCodec' export { ReactionCodec } from './lib/NativeCodecs/ReactionCodec' export { ReadReceiptCodec } from './lib/NativeCodecs/ReadReceiptCodec' export { RemoteAttachmentCodec } from './lib/NativeCodecs/RemoteAttachmentCodec' diff --git a/src/lib/NativeCodecs/GroupChangeCodec.ts b/src/lib/NativeCodecs/GroupChangeCodec.ts deleted file mode 100644 index c5d5b446e..000000000 --- a/src/lib/NativeCodecs/GroupChangeCodec.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - ContentTypeId, - GroupChangeContent, - NativeContentCodec, - NativeMessageContent, -} from '../ContentCodec' - -export class GroupChangeCodec - implements NativeContentCodec -{ - contentKey: 'groupChange' = 'groupChange' - contentType: ContentTypeId = { - authorityId: 'xmtp.org', - typeId: 'group_membership_change', - versionMajor: 1, - versionMinor: 0, - } - // Should never have to encode since only sent from Rust backend - encode(): NativeMessageContent { - return {} - } - - decode(nativeContent: NativeMessageContent): GroupChangeContent { - return nativeContent.groupChange! - } - - fallback(): string | undefined { - return undefined - } -} diff --git a/src/lib/types/ContentCodec.ts b/src/lib/types/ContentCodec.ts index 00b6c93d4..a869931ed 100644 --- a/src/lib/types/ContentCodec.ts +++ b/src/lib/types/ContentCodec.ts @@ -53,14 +53,14 @@ export type RemoteAttachmentContent = RemoteAttachmentMetadata & { url: string } -export type GroupChangeEntry = { - address: string - initiatedByAddress: string +export type GroupUpdatedEntry = { + inboxId: string + initiatedByInboxId: string } -export type GroupChangeContent = { - membersAdded: GroupChangeEntry[] - membersRemoved: GroupChangeEntry[] +export type GroupUpdatedContent = { + membersAdded: GroupUpdatedEntry[] + membersRemoved: GroupUpdatedEntry[] } // This contains a message that has been prepared for sending. @@ -101,7 +101,7 @@ export type NativeMessageContent = { remoteAttachment?: RemoteAttachmentContent readReceipt?: ReadReceiptContent encoded?: string - groupChange?: GroupChangeContent + groupUpdated?: GroupUpdatedContent } export interface JSContentCodec {