Skip to content

Commit

Permalink
[desk-tool] Reset the Changes panel when publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr authored and rexxars committed Oct 6, 2020
1 parent e637cc8 commit 644f127
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/@sanity/desk-tool/src/actions/PublishAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useSyncState, useDocumentOperation, useValidationStatus} from '@sanity/r
import CheckmarkIcon from 'part:@sanity/base/check-icon'
import PublishIcon from 'part:@sanity/base/publish-icon'
import TimeAgo from '../components/TimeAgo'
import {useDocumentHistory} from '../panes/documentPane/documentHistory'

const DISABLED_REASON_TITLE = {
LIVE_EDIT_ENABLED: 'Cannot publish since liveEdit is enabled for this document type',
Expand Down Expand Up @@ -39,6 +40,7 @@ export function PublishAction(props) {
const {publish}: any = useDocumentOperation(id, type)
const validationStatus = useValidationStatus(id, type)
const syncState = useSyncState(id)
const {open: historyOpen, historyController} = useDocumentHistory()

const hasValidationErrors = validationStatus.markers.some(marker => marker.level === 'error')

Expand All @@ -48,7 +50,7 @@ export function PublishAction(props) {
const doPublish = React.useCallback(() => {
publish.execute()
setPublishState('publishing')
}, [publish])
}, [publish, historyController])

React.useEffect(() => {
if (publishScheduled && !syncState.isSyncing && !validationStatus.isValidating) {
Expand All @@ -67,6 +69,12 @@ export function PublishAction(props) {

React.useEffect(() => {
const didPublish = publishState === 'publishing' && !draft
if (didPublish) {
if (historyController.changesPanelActive()) {
// Re-open the panel
historyOpen()
}
}
const nextState = didPublish ? 'published' : null
const delay = didPublish ? 200 : 4000
const timer = setTimeout(() => {
Expand Down

0 comments on commit 644f127

Please sign in to comment.