diff --git a/packages/sanity/src/desk/comments/src/hooks/useCommentOperations.ts b/packages/sanity/src/desk/comments/src/hooks/useCommentOperations.ts index 10ec29f83cf..a3f32446e48 100644 --- a/packages/sanity/src/desk/comments/src/hooks/useCommentOperations.ts +++ b/packages/sanity/src/desk/comments/src/hooks/useCommentOperations.ts @@ -52,7 +52,7 @@ export function useCommentOperations( const authorId = currentUser?.id - const {title, url, toolName} = useNotificationTarget({ + const {documentTitle, toolName, url, workspaceTitle} = useNotificationTarget({ documentId, documentType, }) @@ -76,7 +76,11 @@ export function useCommentOperations( payload: { workspace, }, - notification: {title, url}, + notification: { + documentTitle, + url, + workspaceTitle, + }, tool: toolName, }, target: { @@ -114,14 +118,15 @@ export function useCommentOperations( client, dataset, documentId, + documentTitle, documentType, onCreate, onCreateError, projectId, - title, toolName, url, workspace, + workspaceTitle, ], ) diff --git a/packages/sanity/src/desk/comments/src/hooks/useNotificationTarget.ts b/packages/sanity/src/desk/comments/src/hooks/useNotificationTarget.ts index 9f6150cf918..dc6386dcb08 100644 --- a/packages/sanity/src/desk/comments/src/hooks/useNotificationTarget.ts +++ b/packages/sanity/src/desk/comments/src/hooks/useNotificationTarget.ts @@ -10,9 +10,10 @@ interface NotificationTargetHookOptions { } interface NotificationTargetHookValue { - url: string - title: string + documentTitle: string toolName: string + url: string + workspaceTitle: string } /** @internal */ @@ -21,7 +22,7 @@ export function useNotificationTarget( ): NotificationTargetHookValue { const {documentId, documentType} = opts || {} const schemaType = useSchema().get(documentType) - const {basePath, tools} = useWorkspace() + const {basePath, title: workspaceTitle, tools} = useWorkspace() const activeToolName = useRouterState( useCallback( @@ -42,7 +43,7 @@ export function useNotificationTarget( }, [documentId, documentPreviewStore, schemaType]) const {published, draft} = previewState || {} - const notificationTitle = (draft?.title || published?.title || 'Sanity document') as string + const documentTitle = (draft?.title || published?.title || 'Sanity document') as string const currentUrl = new URL(window.location.href) const deskToolSegment = currentUrl.pathname.split('/').slice(2, 3).join('') @@ -50,8 +51,9 @@ export function useNotificationTarget( const notificationUrl = currentUrl.toString() return { - url: notificationUrl, - title: notificationTitle, + documentTitle, toolName: activeTool?.name || '', + url: notificationUrl, + workspaceTitle, } } diff --git a/packages/sanity/src/desk/comments/src/types.ts b/packages/sanity/src/desk/comments/src/types.ts index 05413eed104..8c4e7ac8a9c 100644 --- a/packages/sanity/src/desk/comments/src/types.ts +++ b/packages/sanity/src/desk/comments/src/types.ts @@ -72,9 +72,10 @@ export interface CommentPath { interface CommentContext { tool: string payload?: Record - notification: { - title: string + notification?: { + documentTitle: string url: string + workspaceTitle: string } }