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

fix: Group is Active #461

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down Expand Up @@ -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
}`
)
}

Expand Down
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
30 changes: 14 additions & 16 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,29 +44,15 @@ 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
isGroupActive: 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
this.peerInboxIds = params.peerInboxIds
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
Expand Down
Loading