Skip to content

Commit

Permalink
refactor(structure): add timeout for reconnecting pane provider
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias committed Sep 24, 2024
1 parent a218c88 commit afec90c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/sanity/src/structure/i18n/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ const structureLocaleStrings = defineLocalesResources('structure', {
/** The document title shown when document title is "undefined" in operation message */
'panes.document-operation-results.operation-undefined-title': 'Untitled',
/** The title of the reconnecting toast */
'panes.document-pane-provider.reconnecting.title': 'Connection lost. Reconnecting…',
'panes.document-pane-provider.reconnecting.title': 'Connection lost. Attempting to reconnect…',
/** The loading message for the document not found pane */
'panes.document-pane.document-not-found.loading': 'Loading document…',
/** The text of the document not found pane if the schema is known */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,11 +749,13 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {

useEffect(() => {
if (connectionState === 'reconnecting') {
pushToast({
id: 'sanity/structure/reconnecting',
status: 'warning',
title: t('panes.document-pane-provider.reconnecting.title'),
})
setTimeout(() => {
pushToast({
id: 'sanity/structure/reconnecting',
status: 'warning',
title: t('panes.document-pane-provider.reconnecting.title'),
})
}, 2000)
}
}, [connectionState, pushToast, t])

Expand Down

0 comments on commit afec90c

Please sign in to comment.