-
Notifications
You must be signed in to change notification settings - Fork 21
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
Changes from 6 commits
7ca505e
a660d97
31f397e
53240fa
b9b6d36
c9bbb45
fb87e3b
4816fd4
bbfe753
79b2526
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import android.util.Base64 | ||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.Client | ||
import org.xmtp.android.library.Conversation | ||
|
||
class ConversationContainerWrapper { | ||
|
||
companion object { | ||
fun encodeToObj(client: Client, conversation: Conversation): Map<String, Any> { | ||
when (conversation.version) { | ||
Conversation.Version.GROUP -> { | ||
return mapOf( | ||
"clientAddress" to client.address, | ||
"id" to conversation.topic, | ||
"createdAt" to conversation.createdAt.time, | ||
"peerAddresses" to conversation.peerAddresses, | ||
"version" to "group", | ||
"topic" to conversation.topic | ||
) | ||
} | ||
else -> { | ||
val context = when (conversation.version) { | ||
Conversation.Version.V2 -> mapOf<String, Any>( | ||
"conversationID" to (conversation.conversationId ?: ""), | ||
// TODO: expose the context/metadata explicitly in xmtp-android | ||
"metadata" to conversation.toTopicData().invitation.context.metadataMap, | ||
) | ||
|
||
else -> mapOf() | ||
} | ||
return mapOf( | ||
"clientAddress" to client.address, | ||
"createdAt" to conversation.createdAt.time, | ||
"context" to context, | ||
"topic" to conversation.topic, | ||
"peerAddress" to conversation.peerAddress, | ||
"version" to if (conversation.version == Conversation.Version.V1) "v1" else "v2", | ||
"conversationID" to (conversation.conversationId ?: ""), | ||
"keyMaterial" to Base64.encodeToString(conversation.keyMaterial, Base64.NO_WRAP) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ContentTypeId } from './types/ContentCodec' | ||
import { DefaultContentTypes } from './types/DefaultContentType' | ||
import * as XMTP from '../index' | ||
|
||
export type SendOptions = { | ||
contentType?: ContentTypeId | ||
} | ||
|
||
export enum ConversationVersion { | ||
V1 = 'v1', | ||
V2 = 'v2', | ||
GROUP = 'group', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated here - 4816fd4 |
||
} | ||
|
||
export interface ConversationContainer< | ||
ContentTypes extends DefaultContentTypes, | ||
> { | ||
client: XMTP.Client<ContentTypes> | ||
createdAt: number | ||
version: ConversationVersion | ||
topic: string | ||
isGroup(): boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove is Group in favor of version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed here - 4816fd4 |
||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated fb87e3b 👍