Skip to content

Commit

Permalink
fix(UseAdaptiveCard): handle missing activity or card
Browse files Browse the repository at this point in the history
  • Loading branch information
CoroDaniel authored and cipak committed Feb 11, 2022
1 parent c594d48 commit 0ccd2cd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/hooks/useAdaptiveCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,24 @@ export default function useAdaptiveCard(activityID) {
.subscribe((activity) => {
const newCard = activitiesAdapter.getAdaptiveCard(activity);

setCard(newCard);
setCard(newCard || {
type: 'AdaptiveCard',
version: '1.0',
body: [{
type: 'TextBlock',
text: 'This message does not contain a card.',
}],
});
}, (error) => {
console.error(error);
setCard({
type: 'AdaptiveCard',
version: '1.0',
body: [{
type: 'TextBlock',
text: `Message could not be loaded. ${error}`,
}],
});
});

cleanup = () => subscription.unsubscribe();
Expand Down

0 comments on commit 0ccd2cd

Please sign in to comment.