Prevent crash when integration associated to a block is no longer installed (#213)

* Prevent crash when integration is not installed for a block

* Format
This commit is contained in:
Samy Pessé
2024-03-05 19:24:51 +00:00
committed by GitHub
parent a9f9f18e66
commit d22944419f
3 changed files with 29 additions and 18 deletions
@@ -17,7 +17,7 @@ import {
import { ContentKitContext, DocumentBlockIntegration } from '@gitbook/api';
import { ContentKit, ContentKitOutput, ContentKitServerContext } from '@gitbook/react-contentkit';
import { renderIntegrationUi } from '@/lib/api';
import { ignoreAPIError, renderIntegrationUi } from '@/lib/api';
import { parseMarkdown } from '@/lib/markdown';
import { tcls } from '@/lib/tailwind';
@@ -72,7 +72,12 @@ export async function IntegrationBlock(props: BlockProps<DocumentBlockIntegratio
context: contentKitContext,
};
const initialOutput = await renderIntegrationUi(block.data.integration, initialInput);
const initialOutput = await ignoreAPIError(
renderIntegrationUi(block.data.integration, initialInput),
);
if (!initialOutput) {
return null;
}
return (
<div className={tcls(style)}>