Skip to content

Commit

Permalink
[desk-tool] Prefer assigned titles over document titles when both exi…
Browse files Browse the repository at this point in the history
…st (#971)
  • Loading branch information
rexxars committed Sep 21, 2018
1 parent cba4921 commit 5086d75
Showing 1 changed file with 7 additions and 6 deletions.
@@ -1,11 +1,12 @@
import React from 'react'
import PropTypes from 'prop-types'
import {combineLatest, concat, of} from 'rxjs'
import {assignWith} from 'lodash'
import {map} from 'rxjs/operators'
import WarningIcon from 'part:@sanity/base/warning-icon'
import {observeForPreview, SanityDefaultPreview} from 'part:@sanity/base/preview'
import NotPublishedStatus from './NotPublishedStatus'
import DraftStatus from './DraftStatus'
import WarningIcon from 'part:@sanity/base/warning-icon'

const isLiveEditEnabled = schemaType => schemaType.liveEdit === true

Expand All @@ -26,15 +27,15 @@ const getMissingDocumentFallback = item => ({
media: WarningIcon
})

const getValueWithFallback = ({isLoading, value, schemaType, draft, published}) => {
const getValueWithFallback = ({value, draft, published}) => {
const snapshot = draft || published
if (!snapshot) {
return getMissingDocumentFallback(value)
}
return {
...snapshot,
...value
}

return assignWith({}, snapshot, value, (objValue, srcValue) => {
return typeof srcValue === 'undefined' ? objValue : srcValue
})
}

export default class DocumentPaneItemPreview extends React.Component {
Expand Down

0 comments on commit 5086d75

Please sign in to comment.