Skip to content

Commit

Permalink
update all the places with group updated
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed May 29, 2024
1 parent f6a17f4 commit 491e985
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions example/src/GroupScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
StaticAttachmentContent,
ReplyContent,
useClient,
GroupChangeContent,
GroupUpdatedContent,
} from 'xmtp-react-native-sdk'
import { ConversationSendPayload } from 'xmtp-react-native-sdk/lib/types'

Expand Down Expand Up @@ -1074,42 +1074,42 @@ 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 ? (
<Text style={{ opacity: 0.5, fontStyle: 'italic' }}>
{`${formatAddress(
content.membersAdded[0].address
content.membersAdded[0].inboxId
)} has been added by ${formatAddress(
content.membersAdded[0].initiatedByAddress
content.membersAdded[0].initiatedByInboxId
)}`}
</Text>
) : (
<Text style={{ opacity: 0.5, fontStyle: 'italic' }}>
{`${
content.membersAdded.length
} members have been added by ${formatAddress(
content.membersAdded[0].initiatedByAddress
content.membersAdded[0].initiatedByInboxId
)}`}
</Text>
))}
{content.membersRemoved.length > 0 &&
(content.membersRemoved.length === 1 ? (
<Text style={{ opacity: 0.5, fontStyle: 'italic' }}>
{`${formatAddress(
content.membersRemoved[0].address
content.membersRemoved[0].inboxId
)} has been removed by ${formatAddress(
content.membersRemoved[0].initiatedByAddress
content.membersRemoved[0].initiatedByInboxId
)}`}
</Text>
) : (
<Text style={{ opacity: 0.5, fontStyle: 'italic', flexWrap: 'wrap' }}>
{`${
content.membersRemoved.length
} members have been removed by ${formatAddress(
content.membersRemoved[0].initiatedByAddress
content.membersRemoved[0].initiatedByInboxId
)}`}
</Text>
))}
Expand Down Expand Up @@ -1172,7 +1172,7 @@ function MessageContents({
)
}
if (contentTypeId === 'xmtp.org/group_membership_change:1.0') {
return <GroupChangeContents content={content} />
return <GroupUpdatedContents content={content} />
}

return (
Expand Down
4 changes: 2 additions & 2 deletions example/src/contentTypes/contentTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
GroupChangeCodec,
GroupUpdatedCodec,
ReactionCodec,
ReplyCodec,
RemoteAttachmentCodec,
Expand All @@ -11,7 +11,7 @@ export const supportedCodecs = [
new ReplyCodec(),
new RemoteAttachmentCodec(),
new StaticAttachmentCodec(),
new GroupChangeCodec(),
new GroupUpdatedCodec(),
]

export type SupportedContentTypes = typeof supportedCodecs
8 changes: 4 additions & 4 deletions ios/Wrappers/DecodedMessageWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Check failure on line 28 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

Cannot find module './lib/NativeCodecs/GroupUpdatedCodec' or its corresponding type declarations.

Check failure on line 28 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

Cannot find module './lib/NativeCodecs/GroupUpdatedCodec' or its corresponding type declarations.

Check failure on line 28 in src/index.ts

View workflow job for this annotation

GitHub Actions / test

Cannot find module './lib/NativeCodecs/GroupUpdatedCodec' or its corresponding type declarations.
export { ReactionCodec } from './lib/NativeCodecs/ReactionCodec'
export { ReadReceiptCodec } from './lib/NativeCodecs/ReadReceiptCodec'
export { RemoteAttachmentCodec } from './lib/NativeCodecs/RemoteAttachmentCodec'
Expand Down
30 changes: 0 additions & 30 deletions src/lib/NativeCodecs/GroupChangeCodec.ts

This file was deleted.

14 changes: 7 additions & 7 deletions src/lib/types/ContentCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -101,7 +101,7 @@ export type NativeMessageContent = {
remoteAttachment?: RemoteAttachmentContent
readReceipt?: ReadReceiptContent
encoded?: string
groupChange?: GroupChangeContent
groupUpdated?: GroupUpdatedContent
}

export interface JSContentCodec<T> {
Expand Down

0 comments on commit 491e985

Please sign in to comment.