Skip to content

Commit

Permalink
[desk-tool] Prevent duplicate reconnection snackbars from appearing w…
Browse files Browse the repository at this point in the history
…hen disconnecting
  • Loading branch information
saasen committed May 19, 2020
1 parent a60d86a commit 887eac4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/@sanity/components/src/snackbar/DefaultSnackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export default class DefaultSnackbar extends React.PureComponent {
// Legacy props
onAction: PropTypes.func,
actionTitle: PropTypes.string,
timeout: PropTypes.number
timeout: PropTypes.number,
preventDuplicate: PropTypes.bool
}

static contextTypes = {
Expand All @@ -43,7 +44,8 @@ export default class DefaultSnackbar extends React.PureComponent {
onClose,
onAction,
isPersisted,
isCloseable
isCloseable,
preventDuplicate
} = this.props

return {
Expand All @@ -58,7 +60,8 @@ export default class DefaultSnackbar extends React.PureComponent {
},
isPersisted,
isCloseable,
autoDismissTimeout: timeout
autoDismissTimeout: timeout,
preventDuplicate
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,12 @@ export default class DocumentPane extends React.PureComponent<Props, State> {
<InspectView value={value} onClose={this.handleHideInspector} />
)}
{connectionState === 'reconnecting' && (
<Snackbar kind="warning" isPersisted title="Connection lost. Reconnecting…" />
<Snackbar
kind="warning"
title="Connection lost. Reconnecting when online…"
isPersisted
preventDuplicate
/>
)}
<DocumentOperationResults id={options.id} type={options.type} />
</TabbedPane>
Expand Down

0 comments on commit 887eac4

Please sign in to comment.