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(comments): addon dataset creation #5577

Merged
merged 1 commit into from
Jan 26, 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {CurrentUser, Tool} from 'sanity'

interface CreateOperationProps {
activeTool: Tool | undefined
client: SanityClient
client: SanityClient | null
comment: CommentCreatePayload
currentUser: CurrentUser
dataset: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ export function useCommentOperations(

const handleCreate = useCallback(
async (comment: CommentCreatePayload) => {
if (!client || !currentUser?.id) return
// Unlike the other operations, we want to proceed with create operation even
// though there is no client available. This is because if there is no client for the
// comments addon dataset, it will be created in the `createOperation`, and the
// comment will be created in that dataset when the client is eventually created.
if (!currentUser?.id) return

await createOperation({
activeTool,
Expand Down
Loading