Skip to content

Commit

Permalink
fix(structure): use useDocumentTitle hook for toast message (#5719)
Browse files Browse the repository at this point in the history
  • Loading branch information
ninaandal authored Feb 13, 2024
1 parent 2518ac4 commit 51ed18d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ import {Translate, useDocumentOperationEvent, useTranslation} from 'sanity'
import {usePaneRouter} from '../../components'
import {structureLocaleNamespace} from '../../i18n'
import {useDocumentPane} from './useDocumentPane'
import {useDocumentTitle} from './useDocumentTitle'

const IGNORE_OPS = ['patch', 'commit']

export const DocumentOperationResults = memo(function DocumentOperationResults() {
const {push: pushToast} = useToast()
const {documentId, documentType, displayed} = useDocumentPane()
const {documentId, documentType} = useDocumentPane()
const {title} = useDocumentTitle()
const event: any = useDocumentOperationEvent(documentId, documentType)
const prevEvent = useRef(event)
const paneRouter = usePaneRouter()
const {t} = useTranslation(structureLocaleNamespace)

//Truncate the document title and add "..." if it is over 25 characters
const documentTitleBase =
(displayed?.title as string) || t('panes.document-operation-results.operation-undefined-title')
const documentTitleBase = title || t('panes.document-operation-results.operation-undefined-title')
const documentTitle =
documentTitleBase.length > 25 ? `${documentTitleBase.slice(0, 25)}...` : documentTitleBase

Expand Down

0 comments on commit 51ed18d

Please sign in to comment.