Skip to content

Commit

Permalink
Fix Typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Risch authored and Alex Risch committed Aug 5, 2024
1 parent f808d51 commit 9975fe5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
15 changes: 6 additions & 9 deletions src/lib/Conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ConversationContainer,
} from './ConversationContainer'
import { DecodedMessage } from './DecodedMessage'
import { Group } from './Group'
import { Group, GroupParams } from './Group'
import { CreateGroupOptions } from './types/CreateGroupOptions'
import { EventTypes } from './types/EventTypes'
import { PermissionPolicySet } from './types/PermissionPolicySet'
Expand Down Expand Up @@ -144,13 +144,7 @@ export default class Conversations<
XMTPModule.subscribeToGroups(this.client.inboxId)
const groupsSubscription = XMTPModule.emitter.addListener(
EventTypes.Group,
async ({
inboxId,
group,
}: {
inboxId: string
group: Group<ContentTypes>
}) => {
async ({ inboxId, group }: { inboxId: string; group: GroupParams }) => {
if (this.known[group.id]) {
return
}
Expand Down Expand Up @@ -293,7 +287,10 @@ export default class Conversations<
this.known[conversationContainer.topic] = true
if (conversationContainer.version === ConversationVersion.GROUP) {
return await callback(
new Group(this.client, conversationContainer as Group<ContentTypes>)
new Group(
this.client,
conversationContainer as unknown as GroupParams
)
)
} else {
return await callback(
Expand Down
28 changes: 13 additions & 15 deletions src/lib/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ import * as XMTP from '../index'

export type PermissionUpdateOption = 'allow' | 'deny' | 'admin' | 'super_admin'

export interface GroupParams {
id: string
createdAt: number
peerInboxIds: InboxId[]
creatorInboxId: InboxId
topic: string
name: string
isActive: boolean
imageUrlSquare: string
description: string
}

export class Group<
ContentTypes extends DefaultContentTypes = DefaultContentTypes,
> implements ConversationContainer<ContentTypes>
Expand All @@ -32,21 +44,7 @@ export class Group<
description: string
// pinnedFrameUrl: string

constructor(
client: XMTP.Client<ContentTypes>,
params: {
id: string
createdAt: number
peerInboxIds: InboxId[]
creatorInboxId: InboxId
topic: string
name: string
isActive: boolean
imageUrlSquare: string
description: string
// pinnedFrameUrl: string
}
) {
constructor(client: XMTP.Client<ContentTypes>, params: GroupParams) {
this.client = client
this.id = params.id
this.createdAt = params.createdAt
Expand Down

0 comments on commit 9975fe5

Please sign in to comment.