From f808d51b7f06ee4f3e5c7af2b8c355ac2d63dcd7 Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Mon, 5 Aug 2024 11:04:24 -0600 Subject: [PATCH 1/2] fix: Group is Active Updated params to match native params Updated test --- example/src/tests/groupTests.ts | 6 +++++- src/lib/Group.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index 68d6cd818..d4459baea 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -1010,6 +1010,8 @@ test('can list groups', async () => { `Group 2 url for alix should be www.group2image.com but was ${alixGroup2?.imageUrlSquare}` ) + assert(boGroup1?.isGroupActive === true, `Group 1 should be active for bo`) + return true }) @@ -1343,7 +1345,9 @@ test('can make a group with admin permissions', async () => { if ((await group.permissionPolicySet()).addMemberPolicy !== 'admin') { throw Error( - `Group permission level should be admin but was ${(await group.permissionPolicySet()).addMemberPolicy}` + `Group permission level should be admin but was ${ + (await group.permissionPolicySet()).addMemberPolicy + }` ) } diff --git a/src/lib/Group.ts b/src/lib/Group.ts index 96de1fcfe..0f8a3cd52 100644 --- a/src/lib/Group.ts +++ b/src/lib/Group.ts @@ -41,7 +41,7 @@ export class Group< creatorInboxId: InboxId topic: string name: string - isGroupActive: boolean + isActive: boolean imageUrlSquare: string description: string // pinnedFrameUrl: string @@ -54,7 +54,7 @@ export class Group< this.topic = params.topic this.creatorInboxId = params.creatorInboxId this.name = params.name - this.isGroupActive = params.isGroupActive + this.isGroupActive = params.isActive this.imageUrlSquare = params.imageUrlSquare this.description = params.description // this.pinnedFrameUrl = params.pinnedFrameUrl From 9975fe55f4a4973dab658e6f9d53355b89ca9130 Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Mon, 5 Aug 2024 11:17:03 -0600 Subject: [PATCH 2/2] Fix Typescript errors --- src/lib/Conversations.ts | 15 ++++++--------- src/lib/Group.ts | 28 +++++++++++++--------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/lib/Conversations.ts b/src/lib/Conversations.ts index c274fdf86..693df85ec 100644 --- a/src/lib/Conversations.ts +++ b/src/lib/Conversations.ts @@ -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' @@ -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 - }) => { + async ({ inboxId, group }: { inboxId: string; group: GroupParams }) => { if (this.known[group.id]) { return } @@ -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) + new Group( + this.client, + conversationContainer as unknown as GroupParams + ) ) } else { return await callback( diff --git a/src/lib/Group.ts b/src/lib/Group.ts index 0f8a3cd52..9704cac8e 100644 --- a/src/lib/Group.ts +++ b/src/lib/Group.ts @@ -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 @@ -32,21 +44,7 @@ export class Group< description: string // pinnedFrameUrl: string - constructor( - client: XMTP.Client, - 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, params: GroupParams) { this.client = client this.id = params.id this.createdAt = params.createdAt