Skip to content

Commit

Permalink
fix: run block initialize fn only once
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyphilemon committed Jan 29, 2025
1 parent 5bb62f1 commit 02594e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion blocks/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { getSuggestionsByDocumentId } from '@/lib/db/queries';

export async function getSuggestions({ documentId }: { documentId: string }) {
const suggestions = await getSuggestionsByDocumentId({ documentId });
return suggestions;
return suggestions ?? [];
}
4 changes: 2 additions & 2 deletions components/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ function PureBlock({
}

useEffect(() => {
if (block && block.documentId !== 'init') {
if (block.documentId !== 'init') {
if (blockDefinition.initialize) {
blockDefinition.initialize({
documentId: block.documentId,
setMetadata,
});
}
}
}, [block, blockDefinition, setMetadata]);
}, [block.documentId, blockDefinition, setMetadata]);

return (
<AnimatePresence>
Expand Down

0 comments on commit 02594e3

Please sign in to comment.