Skip to content

Commit

Permalink
fix(messenger): allow buttonless card (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvitora committed May 1, 2023
1 parent 1cdfceb commit adb389a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/channels/src/messenger/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface MessengerCard {
title: string
image_url?: string
subtitle?: string
buttons: MessengerButton[]
buttons?: MessengerButton[]
}

export interface MessengerButton {
Expand Down
10 changes: 1 addition & 9 deletions packages/channels/src/messenger/renderers/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,11 @@ export class MessengerCarouselRenderer extends CarouselRenderer {
}

endRenderCard(context: Context, card: CardContent) {
if (context.buttons.length === 0) {
context.buttons.push({
type: 'postback',
title: card.title,
payload: card.title
})
}

context.cards.push({
title: card.title,
image_url: card.image ? card.image : undefined,
subtitle: card.subtitle,
buttons: context.buttons
...(context.buttons?.length && { buttons: context.buttons })
})
}

Expand Down

0 comments on commit adb389a

Please sign in to comment.