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

Group Messages Decoding #245

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 13 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ 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'
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

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -484,11 +487,10 @@ 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 }
2 changes: 1 addition & 1 deletion src/lib/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading