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

Conversation and Group implement common interface + Stream all #256

Merged
merged 10 commits into from
Feb 14, 2024

Conversation

cameronvoell
Copy link
Contributor

@cameronvoell cameronvoell commented Feb 13, 2024

Added conversations.streamAll() function which streams ConversationContainer.

Group and Conversation both implement the ConversationContainer interface. You can determine if a ConversationContainer is a Group or Conversation by checking ConversationContainer.version which is of type ConversationVersion:

import { DefaultContentTypes } from './types/DefaultContentType'
import * as XMTP from '../index'

export enum ConversationVersion {
  DIRECT = 'DIRECT',
  GROUP = 'GROUP',
}

export interface ConversationContainer<
  ContentTypes extends DefaultContentTypes,
> {
  client: XMTP.Client<ContentTypes>
  createdAt: number
  version: ConversationVersion
  topic: string
}

See new test case for usage example: https://github.com/xmtp/xmtp-react-native/pull/256/files#diff-ad2a5f900212586906998f46d89003c169d2425c5ad8f5b5ba82fa53fe254478R583-R668

createdAt: number
version: ConversationVersion
topic: string
isGroup(): boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove is Group in favor of version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed here - 4816fd4

Comment on lines 10 to 12
V1 = 'v1',
V2 = 'v2',
GROUP = 'group',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DirectMessage and Group RN doesn't need to know about V1 or V2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated here - 4816fd4

"conversationID" to (conversation.conversationId ?: ""),
"keyMaterial" to Base64.encodeToString(conversation.keyMaterial, Base64.NO_WRAP)
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe clean this up by using the existing wrapper classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated fb87e3b 👍

@cameronvoell cameronvoell marked this pull request as ready for review February 14, 2024 18:27
@cameronvoell cameronvoell requested a review from a team as a code owner February 14, 2024 18:27
Copy link
Contributor

@nplasterer nplasterer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -23,7 +23,7 @@ struct ConversationWrapper {
"createdAt": UInt64(conversation.createdAt.timeIntervalSince1970 * 1000),
"context": context,
"peerAddress": conversation.peerAddress,
"version": conversation.version == .v1 ? "v1" : "v2",
"version": "DIRECT",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to future self that this will need to be noted in the release notes as a breaking change.

@cameronvoell cameronvoell merged commit bcd9875 into beta Feb 14, 2024
5 of 6 checks passed
@cameronvoell cameronvoell deleted the cv/conversation-interface branch February 14, 2024 18:49
Copy link
Contributor

🎉 This PR is included in version 1.27.0-beta.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

🎉 This PR is included in version 1.28.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

🎉 This PR is included in version 1.30.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

🎉 This PR is included in version 1.31.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants