mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Display an error message when the synctex request fails (#27523)
GitOrigin-RevId: 4a57058386ba8b11dee90ef13e374411db54e2cc
This commit is contained in:
@@ -21,6 +21,12 @@ export const SynctexFileErrorToast = () => {
|
||||
)
|
||||
}
|
||||
|
||||
export const SynctexRequestErrorToast = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return <span>{t('synctex_error_recompile_and_try_again')}</span>
|
||||
}
|
||||
|
||||
const generators: GlobalToastGeneratorEntry[] = [
|
||||
{
|
||||
key: 'synctex:file-error',
|
||||
@@ -32,6 +38,16 @@ const generators: GlobalToastGeneratorEntry[] = [
|
||||
isDismissible: true,
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'synctex:request-error',
|
||||
generator: () => ({
|
||||
content: <SynctexRequestErrorToast />,
|
||||
type: 'warning',
|
||||
autoHide: true,
|
||||
delay: 4000,
|
||||
isDismissible: true,
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
export default generators
|
||||
@@ -45,3 +61,13 @@ export const showFileErrorToast = () => {
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export const showSynctexRequestErrorToast = () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('ide:show-toast', {
|
||||
detail: {
|
||||
key: 'synctex:request-error',
|
||||
},
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ import useEventListener from '@/shared/hooks/use-event-listener'
|
||||
import { CursorPosition } from '@/features/ide-react/types/cursor-position'
|
||||
import { isValidTeXFile } from '@/main/is-valid-tex-file'
|
||||
import { PdfScrollPosition } from '@/shared/hooks/use-pdf-scroll-position'
|
||||
import { showFileErrorToast } from '@/features/pdf-preview/components/synctex-toasts'
|
||||
import {
|
||||
showFileErrorToast,
|
||||
showSynctexRequestErrorToast,
|
||||
} from '@/features/pdf-preview/components/synctex-toasts'
|
||||
import { sendMB } from '@/infrastructure/event-tracking'
|
||||
|
||||
export default function useSynctex(): {
|
||||
@@ -125,7 +128,10 @@ export default function useSynctex(): {
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(debugConsole.error)
|
||||
.catch(error => {
|
||||
showSynctexRequestErrorToast()
|
||||
debugConsole.error(error)
|
||||
})
|
||||
.finally(() => {
|
||||
if (isMounted.current) {
|
||||
setSyncToPdfInFlight(false)
|
||||
@@ -236,7 +242,10 @@ export default function useSynctex(): {
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(debugConsole.error)
|
||||
.catch(error => {
|
||||
debugConsole.error(error)
|
||||
showSynctexRequestErrorToast()
|
||||
})
|
||||
.finally(() => {
|
||||
if (isMounted.current) {
|
||||
setSyncToCodeInFlight(false)
|
||||
|
||||
Reference in New Issue
Block a user