Skip to content

Commit

Permalink
refactor(structure): add timeout clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias committed Sep 24, 2024
1 parent 33b825c commit 9dcb7c7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -748,15 +748,19 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {
)

useEffect(() => {
let timeout: NodeJS.Timeout
if (connectionState === 'reconnecting') {
setTimeout(() => {
timeout = setTimeout(() => {
pushToast({
id: 'sanity/structure/reconnecting',
status: 'warning',
title: t('panes.document-pane-provider.reconnecting.title'),
})
}, 2000) // 2 seconds, we can iterate on the value
}
return () => {
if (timeout) clearTimeout(timeout)
}
}, [connectionState, pushToast, t])

const disableBlurRef = useRef(false)
Expand Down

0 comments on commit 9dcb7c7

Please sign in to comment.